zoukankan      html  css  js  c++  java
  • 使用Calendar加一天,减一天

    public class Test {
        public static void main(String[] args) {
            Calendar c=Calendar.getInstance();
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            //今天
            String today=df.format(c.getTime());
            System.out.println(today);//比如今天是2017-02-08,则将输出2017-02-08
            
            //今天-1天(昨天)
            c.add(Calendar.DAY_OF_MONTH, -1);
            //将昨天格式化
            String yesterday=df.format(c.getTime());
            System.out.println(yesterday);//将输出2017-02-07
            
            //昨天+2天(明天)
            c.add(Calendar.DAY_OF_MONTH, 2);
            //将明天格式化
            String tomorrow=df.format(c.getTime());
            System.out.println(tomorrow);//将输出2017-02-09
            
            
            //明天+1天(后天)
            c.add(Calendar.DAY_OF_MONTH,1);
            //将后天格式化
              String nextTomorrow=df.format(c.getTime());
              System.out.println(nextTomorrow);//将输出2017-02-10
        }
    
    }
  • 相关阅读:
    SQL SEREVR IO
    INTEL
    windows performance
    The DiskSpd Storage Performance Tool
    machine Learning
    NOSQL
    X64 Deep Dive
    Debugging and performance,ETW
    Disk Performance
    WCF transport-and-message-security
  • 原文地址:https://www.cnblogs.com/chunyansong/p/6377064.html
Copyright © 2011-2022 走看看