Java does not produce correct time zone information

Use getDisplayName(daylight, style), passing in true for daylight. This'll print:

America/New_York;Eastern Daylight Time; -4.000000

But you'll have to determine whether the current time is in daylight savings time or not (or it'll always return "Daylight Time", even in the fall and winter). This should do the trick:

String[] allTimeZones = TimeZone.getAvailableIDs();
Date now = new Date();
for (int i = 0; i < allTimeZones.length; i++) {
    TimeZone tz = TimeZone.getTimeZone(allTimeZones[i]);
    System.out.format("%s;%s; %f \n", allTimeZones[i], 
            tz.getDisplayName(tz.inDaylightTime(now), TimeZone.LONG), 
            (float) (tz.getOffset(now.getTime())/3600000.0));
}

Tags:

Java

Timezone