java-json日期字符串转换

                String valueStr = value.toString();
if(StringUtils.isBlank(valueStr) || "null".equals(valueStr)) return;
/*long time = DateTimeUtils.str2Date(valueStr, DateTimeUtils.FORMAT_yyyy_MM_dd).getTime();
method.invoke(object, new Date(time));*/
JSONObject json = JSONObject.fromObject(valueStr); String date = DateTimeUtils.date2StrDate( new Date(Long.parseLong(json.get("time").toString())), DateTimeUtils.FORMAT_yyyyMMdd); int hours = Integer.parseInt(json.get("hours").toString());
if( hours<10){
date = date+"0"+hours;
}else{
date = date+hours;
}
int minutes = Integer.parseInt(json.get("minutes").toString());
if( minutes<10){
date = date+"0"+minutes;
}else{
date = date+minutes;
}
int seconds = Integer.parseInt(json.get("seconds").toString());
if( seconds<10){
date = date+"0"+seconds;
}else{
date = date+seconds;
}
//System.out.println(date);
DateTimeUtils.str2Date(date, DateTimeUtils.FORMAT_yyyyMMddHHmmss);
上一篇:前端学HTTP之安全HTTP


下一篇:线程池(ThreadPool)