hello
I am new to
Java and developing First Java Application. Please refer following code and the output.
System is Kubuntu 9.10 JDK 1.6 Repository Install, STS 2.3.2.
public static void main(
String[] args) {
// Mon Jan 01 05:53:20 IST 1900
SimpleDateFormat fmt = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
TimeZone tz = TimeZone.getDefault();
System.out.println("RawOffset = " + tz.getRawOffset() + " useDaylightTime = " + tz.useDaylightTime());
try {
Date dt1 = fmt.parse("Mon Jan 01 05:30:00 IST 1900");
Date dt2 = fmt.parse("Mon Jan 01 05:29:59 IST 1900");
System.out.println("date = " + dt1 + " offset = " + tz.getOffset(dt1.getTime()) + " getTime = "
+ dt1.getTime());
System.out.println("date = " + dt2 + " offset = " + tz.getOffset(dt2.getTime()) + " getTime = "
+ dt2.getTime());
}
catch (ParseException e) {
e.printStackTrace();
}
}
}
RawOffset = 19800000 useDaylightTime = false
date = Mon Jan 01 05:53:20 IST 1900 offset = 21200000

getTime = -2208988800000
date = Mon Jan 01 05:29:59 IST 1900 offset = 19800000

getTime = -2208988801000
I am confused why diff of 1 sec at threshold of timezone offset of 05:30 is converting date to 05:53:20 when
the raw date millis have changed correctly by 1 sec. You can see that offset has also shifted by 23:20 so
addition of 23:20 can be understood but why should it happen ? How can I get correct time of 05:30 if its
default behavior.
Thanks and Best Regards.
Raja