public static void main(String[] args) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date currentDate = new Date(System.currentTimeMillis());
Calendar calender = Calendar.getInstance();
calender.setTime(currentDate);
System.out.println("当天时间:"+currentDate.toLocaleString());
calender.add(Calendar.DATE, 3);
calender.add(Calendar.SECOND, -1);
Date dueTime=null;
try {
dueTime = simpleDateFormat.parse(simpleDateFormat.format(calender.getTime()).toString());
} catch (ParseException e) {
e.printStackTrace();
}
System.out.println("input into endDate:"+dueTime.toLocaleString());
}
小例子--当前时间加三天时间减一秒
最新推荐文章于 2021-09-07 17:41:10 发布