Resetting the time part of a timestamp in Java

后端 未结 10 1226
慢半拍i
慢半拍i 2020-12-04 23:56

In Java, given a timestamp, how to reset the time part alone to 00:00:00 so that the timestamp represents the midnight of that particular day ?

In T-SQL, this query

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 00:47

    If you're using commons lang you can call DateUtils.truncate. Here's the javadoc documentation.

    It does the same thing @Alex Miller said to do.

提交回复
热议问题