I live and write code in the US Central time, it's late spring and the US is in daylight savings. I'm on vacation on the East coast where it's Eastern time and daylight savings time also applies. I've changed the time zone on my Linux machine from Chicago to New York. My program, however, thinks it's in Eastern time zone but not on daylight savings time.
How do I get the reliably correct time zone data directly from the user's computer?
JDK 1.6.0_12
NB 6.5.1
Calendar cal=Calendar.getInstance();
TimeZone tz=cal.getTimeZone();
TimeZone man=TimeZone.getTimeZone("EST5EDT"); // because i'm the omniscient programmer who knows the user is sitting in ney york city
System.out.println("Java says it's: "+tz.getDisplayName()+" daylight savings time is "+tz.inDaylightTime(cal.getTime()));
System.out.println("Omniscient programmer says it's "+man.getDisplayName()+" daylight savings time is "+man.inDaylightTime(cal.getTime()));
New York:
Java says it's: GMT-05:00 daylight savings time is false
Omniscient programmer says it's Eastern Standard Time daylight savings time is true
Chicago:
Java says it's: Central Standard Time daylight savings time is true
Omniscient programmer says it's Eastern Standard Time daylight savings time is true