I am trying to adjust the current time to get the previous hour time on the hour boundaryfor eg: if the current time is say 10:45 AM I am trying to get the adjusted time as 10:AM, the below code works for most part, but I tried to run it on a machine in IST (Indian Standard Time ) for some reason it goes back to 10:30AM not 10:00 AM, But when I run in PST,EDT,EST it works fine.
Below is what I tried , can any tell me why this behavior , I am using System.currentTimeMillis so the longs value should be independent of timezone right ?
long adjustedTime = System.currentTimeMillis();
long resolution = 3600000L;
long rem = (int) Math.IEEEremainder( adjustedTime , resolution );
if ( rem < 0 )
rem = resolution + rem;
adjustedTime = adjustedTime - rem ;
return adjustedTime;