I have time in epoch format (as Java long variable).
I want to convert it to nearest hour as well as day with respect to Indian Standard Time (IST).
For example, if the epoch time is 1372618032000 (7/1/2013 12:17:12 AM IST), then i want to get 1372620600000 (7/1/2013 1:00:00 AM IST).
Similarly for day rounding. I want to get 1372703400 (7/2/2013 12:00:00 AM IST). [Starting of the next day.]
I have gone through some documentation of Java Date, Java Calendar, Apache DateUtils, and JodaTime.
But i am not able to figure out what is the correct and best way to do this ?
NOTE: I want to round with respect to IST.
Certainly, you won't get a method to accomplish this.
Why not use
java.util.Calendar
's methodsget(int field)
andset(int field, int value)
. I'm positive that it can be done with these methods and a bit of rounding logic.