texasbruce texasbruce - 21 days ago 9
Java Question

Wrong Daylight Saving Offset Returned from Timezone Object

I have the following code:

java.util.TimeZone tz = java.util.TimeZone.getDefault();
System.out.println("Server DS Offset: " + tz.getDSTSavings());


Right now the Daylight saving is off, so I was expecting it to return 0, but it still returns 3600000.

Server is
Solaris 10


date
command returns:

Friday, November 11, 2016 4:27:12 PM EST


env
returns:

TZ=Canada/Eastern

Answer

How about Determine whether daylight savings time dst is active

What you got in your code is TimeZone attribute about what is offset for DST. In the world some offsets are 30 min. some do not have any. So, if Timezone follows DST then you got this value.

Comments