Java 8 date-time: get start of day from ZonedDateTime

后端 未结 3 1579
慢半拍i
慢半拍i 2020-12-25 09:34

Is there any difference between these:

zonedDateTime.truncatedTo(ChronoUnit.DAYS);

zonedDateTime.toLocalDate().atStartOfDay(zonedDateTime.getZone());
         


        
3条回答
  •  天命终不由人
    2020-12-25 09:52

    Note there's also another way of doing it:

    zonedDateTime.with(LocalTime.MIN);
    

    which produces the same result as truncatedTo

提交回复
热议问题