2015/9/6
ThreadLocal:该类提供了线程局部变量,这样可以生成对每个线程唯一的局部标识符。
2015/9/18
1.乱码问题:
js:xdata = encodeURI(encodeURI(xdata));
java:fUrl = URLDecoder.decode(URLDecoder.decode(fUrl,"utf-8"),"utf-8");
2.数据库查询返回的resultSet的处理:
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
String aa = rs.getString("DNS");
...
}
2015/9/23
1.TreeMap中的键值对会进行自然排序,HaspMap则不会
2015/11/10
1.车辆:两年,如查封开始时间为2015-10-27,查封结束时间为2017-10-26的设置;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
String jssj = null;
int gap = 0;
try {
Date date = sdf.parse(kssj);
cal.setTime(date);
cal.add(Calendar.YEAR, gap);
cal.add(Calendar.DAY_OF_MONTH, -1);
date = cal.getTime();
jssj = sdf.format(date);
} catch (ParseException e) {
Logger.logger.error("获取冻结结束时间失败:",e);
}
return jssj;
<另一相似例子:添加年份>
(<select id="NF" name="nf" class="Bordered" style="70px">
<%
Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR)+1;
for(int i=year;i>=(year-9);i--){
%>
<option value="<%=i%>" <%if(i==year-1){%>selected<%} %>><%=i%></option>
<%
}
%>
</select>)
2015/12/8
1..EL表达式,可以取出域中的数据,如${requestScope.id}
2015/12/21
1.SQL语句:date_format(CJSJ,'%Y') = date_format(now(),'%Y') //本年新录用总人数
2.保留小数点后几位: round(avg(A.NL),3)保留小数点后3位(mysql)
java : (1)Math.round();(2)DecimalFormat("#.##%");(3)。。。
2015/12/31
1.迭代获取数据
public String getNodeValue(List list, String Node) {
Iterator it = list.iterator();
if (it.hasNext()) {
Element styleElement = (Element) it.next();
Iterator memo = styleElement.elementIterator(Node);
if (memo.hasNext()) {
Element memostring = (Element) memo.next();
return memostring.getTextTrim();
} else {
return "";
}
} else {
return "";
}
}
2016/2/3
1.获取编号,如LY-1501-1111?
public static String getNewRkdNum(String rkdNum) {
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyMM");
String d = sdf.format(date);
String mon = d.substring(2,4);
if (isEmptyOrNull(rkdNum)) {
rkdNum = d + "-"
+ "00001";
} else {
String rkMon = rkdNum.substring(rkdNum.indexOf("-")+1,rkdNum.lastIndexOf("-"));
if(rkMon.endsWith(mon)){
String rknum = rkdNum.substring(rkdNum.lastIndexOf("-") + 1,
rkdNum.length());
int n = Integer.parseInt(rknum);
int num = n + 1;
if (num < 10) {
rknum = "0000" + num;
} else if (num < 100 && num >= 10) {
rknum = "000" + num;
} else if (num < 1000 && num >= 100) {
rknum = "00" + num;
} else if (num < 10000 && num >= 1000) {
rknum = "0" + num;
} else {
rknum = "" + num;
}
rkdNum = rkdNum.substring(0, rkdNum.indexOf("-") + 1) + d + "-"
+ rknum;
}else{
rkdNum = rkdNum.substring(0, rkdNum.indexOf("-") + 1) + d + "-" + "00001";
}
}
return rkdNum;
}
2.JAVA设置登录密码(相关md5的知识,java自带...)
String encodePwd = new MD5().getMD5ofStr(newPwd);