date - Why is java.sql.Time object giving different times one year apart? -
i'm bit confused how java.sql.time object calculates time.
i'm trying setup timer @ time everyday. however, when calculating time, place alarm, seem placing alarm 1 hour ahead of should be.
this starts happening 494 days ago though (current date 7/17/13). occurs if go farther (such 1000 days ago), , i'm guessing cycles through +1 hour , +0 hours every couple hundred of days.
i subtract hour input time, understand why happening.
private static long onedayinmill = timetomill(24, 0); private static long remindertime = timetomill(13 + 6, 25); //military time; starts @ 18, not 0 reason private static long currenttimeinmill = system.currenttimemillis() % onedayinmill; private static long currentdayinmill = system.currenttimemillis() - currenttimeinmill; system.out.println(new time(currentdayinmill - (onedayinmill*495)+ remindertime).tostring()); // displays 13:25:00 (as expect) system.out.println(new time(currentdayinmill - (onedayinmill*494)+ remindertime).tostring()); // displays 14:25:00 (not expect) public static long timetomill(int hr, int min){ //out of bounds return (hr*60*60*1000 + min*60*1000); }
i think time zone used computer cst (that's outputs when output date java.util.date object)
sorry if question bit confusing
rgettman , dave bartlett right. if print out date object 495 days ago receive
sat mar 10 18:00:00 cst 2012
if print out date object 494 days ago receive:
sun mar 11 19:00:00 cdt 2012
Comments
Post a Comment