zoukankan      html  css  js  c++  java
  • 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);
                
  • 相关阅读:
    实体类实现序列化
    异常处理
    Springboot的模块化使用
    Springboot的开始
    RxJava用法
    okhttp的Post方式
    OKhttp使用
    soundPool声音池
    ScheduledExecutor定时器
    timer定时器
  • 原文地址:https://www.cnblogs.com/hwaggLee/p/5582770.html
Copyright © 2011-2022 走看看