zoukankan      html  css  js  c++  java
  • Java处理时间格式

    在Java处理中 显示的是时间格式问题

    说明以下数据库取出来的时间:

    很多电商需要显示 以下是代码:

      List<Map<String,Object>> zxinfo = helpDetailsDao.zxinfo(param);
            for (Map<String, Object> consultationInfo : zxinfo) {
                //处理时间格式
                String alreadyTime = DateUtils.dateFormat((Date) consultationInfo.get("createdTime"), "yyyy/MM/dd HH:mm:ss");
                //判断要处理的时间是否为空
                if(alreadyTime!=null){
                    SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd 00:00:00");//设置日期格式
                    String nowTime = df.format(new Date());
                    String time1 = alreadyTime.subSequence(0, 10).toString();
                    String time2 = nowTime.subSequence(0, 10).toString();
                    if (time1.equals(time2)) {//同一天
                        String createdTime = alreadyTime.subSequence(11, 16).toString();//截取当天   时,分
                        consultationInfo.put("createdTime", createdTime);
                    } else {//不同一天
                        String createdTime = alreadyTime.subSequence(0, 10).toString();//截取当天   年,月,日
                        consultationInfo.put("createdTime", createdTime);
                    }
                }
            }
            return zxinfo;

  • 相关阅读:
    POJ 1201 Intervals(差分约束 区间约束模版)
    POJ 3660 Cow Contest(求图的传递性)
    POJ 2267 From Dusk till Dawn or: Vladimir the Vampire(最短路变形)
    三角形面积
    欧几里得算法及扩展算法。
    康托展开和排列枚举方式
    并查集 HDU-4424
    poj 2513 并查集,Trie(字典树), 欧拉路径
    hdu 4486
    Pythagorean Triples CodeForces
  • 原文地址:https://www.cnblogs.com/wangzn/p/7159151.html
Copyright © 2011-2022 走看看