How to obtain the start time and end time of a day?

前端 未结 14 911
心在旅途
心在旅途 2020-11-27 10:23

How to obtain the start time and end time of a day?

code like this is not accurate:

 private Date getStartOfDay(Date date) {
    Calendar calendar =          


        
14条回答
  •  臣服心动
    2020-11-27 10:40

    Additional way of finding start of day with java8 java.time.ZonedDateTime instead of going through LocalDateTime is simply truncating the input ZonedDateTime to DAYS:

    zonedDateTimeInstance.truncatedTo( ChronoUnit.DAYS );
    

提交回复
热议问题