package com.date.demo;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* 生成当前时间后一天时间零点 例如:当前时间为2018/7/3 15:24:30 生成时间为2018/7/4 00:00:00
*/
public class DateDemo {
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
calendar.add(Calendar.DAY_OF_MONTH, 1);
Date date = new Date();
date = calendar.getTime();
System.out.println(date);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String str = sdf.format(date);
System.out.println(str);
}
}
获取当前日期的后一天
最新推荐文章于 2024-03-11 17:47:19 发布