Set time to 00:00:00

前端 未结 12 2123
时光说笑
时光说笑 2020-11-29 20:04

I have a problem resetting hours in Java. For a given date I want to set the hours to 00:00:00.

This is my code :

/**
     * Resets milliseconds, se         


        
12条回答
  •  有刺的猬
    2020-11-29 20:27

    One more JAVA 8 way:

    LocalDateTime localDateTime = LocalDateTime.now().truncatedTo(ChronoUnit.HOURS);
    

    But it's a lot more useful to edit the date that already exists.

提交回复
热议问题