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);
            

 

posted @ 2016-06-14 08:55  243573295  阅读(701)  评论(0编辑  收藏  举报