zoukankan      html  css  js  c++  java
  • JAVA------14.今日和昨日时间转换

    //今日
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            Date date = new Date();
            String getTime = simpleDateFormat.format(date);
            int tostartTime=DateUtil.Date2TimeStamp(getTime+" 00:00:00", "yyyy-MM-dd HH:mm:ss");
            int toendTime=DateUtil.Date2TimeStamp(getTime+" 24:00:00", "yyyy-MM-dd HH:mm:ss");
    
            //昨日
            Calendar c = Calendar.getInstance();  
            c.setTime(date);  
            int day = c.get(Calendar.DATE);  
            c.set(Calendar.DATE, day - 1);
            String yesday = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()); 
            int yesstartTime=DateUtil.Date2TimeStamp(yesday+" 00:00:00", "yyyy-MM-dd HH:mm:ss");
            int yesendTime=DateUtil.Date2TimeStamp(yesday+" 24:00:00", "yyyy-MM-dd HH:mm:ss");
            //昨日 0点
            pd.put("yesstartTime", yesstartTime);
            //昨日23点
            pd.put("yesendTime", yesendTime);
            //今日 0点
            pd.put("tostartTime", tostartTime);
            //今日 23点
            pd.put("toendTime", toendTime);
  • 相关阅读:
    构建之法阅读笔记05
    第十一周的学习进度条
    第十周的学习进度条
    第九周的学习进度条
    UI分析之石家庄铁道大学官网
    个人工作总结10
    个人工作总结09
    Lua 笔记16
    Lua 笔记15
    Lua 笔记14
  • 原文地址:https://www.cnblogs.com/coriander/p/6835721.html
Copyright © 2011-2022 走看看