Java获得年月日+1,推迟一天的日期。返回长度为8的字符串日期

import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class TomorrowDate {
    public static void main(String[] args) {
        Format f = new SimpleDateFormat("yyyyMMdd");
        Date today = new Date();
        Calendar c = Calendar.getInstance();
        c.setTime(today);
        c.add(Calendar.DAY_OF_MONTH, 1);// 今天+1天
        Date tomorrow = c.getTime();
        System.out.print(f.format(tomorrow));//输出长度为8的字符串日期
    }
}

猜你喜欢

转载自blog.csdn.net/matrixZCL/article/details/99953375
今日推荐