I want to round a java.util.Date
object to the end of the day, e.g. rounding 2016-04-21T10:28:18.109Z
to 2016-04-22T00:00:00.000Z
.
I saw Java Date rounding, but wasn't able to find something compareable for the end of the day. It also is not the same as how to create a Java Date object of midnight today and midnight tomorrow?, because I don't want to create a new Date
(midnight today or tomorrow), but the next midnight based on any given date.
The DateUtils.ceiling serves your purpose. Pass Calendar.DATE
for field value.