JAVA 取当前系统时间后三天零时(LocalDateTime)/获取指定年月日

//当前系统时间
LocalDateTime now = LocalDateTime.now();
//输出now:2021-01-26T12:22:21.319
System.out.println(now);
//当前系统时间三天后
LocalDateTime threeDaysLater = now.plusDays(3);
//输出threeDaysLater:2021-01-29T12:22:21.319 
System.out.println(threeDaysLater);
//当前系统时间三天后零时
LocalDateTime midThreeDays= LocalDateTime.of(threeDaysLater.toLocalDate(), LocalTime.MIN);
//输出midThreeDays:2021-01-29T00:00
System.out.println(midThreeDays);


//LocalDate获取当前系统日期

LocalDate data= LocalDate.now();

//获取指定年月日
LocalDate localDate = LocalDate.of(2021, 1, 1)

//获取前一天的日期

LocalDate timeBf=localDate.plusDays(-1);(2020-12-31)

 

posted @ 2021-01-26 12:28  哎丫丫呀喂  阅读(2582)  评论(0编辑  收藏  举报