File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Timezone won't display local Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Timezone won Watch "Timezone won New topic

Timezone won't display local

randy reed

Joined: Dec 13, 2012
Posts: 4
Hi All,

So this should be simple, but I can't figure it out. No matter what I do, my local timezone displays as GMT-5:00.
I need it to display as EDT/EST because I want to set a milli date and then query whether its in daylight savings time or not
but setting the timezone object with tz.setTimeZone("America/New_York") displays GMT-5:00
when I display a date in september. I've tried setting the user.timezone property in sys.
I've tried setting in SimpleDateFormat as well. My Code looks like this:

My output returns:
12/14/2012 05:47 GMT
Timezone =GMT-05:00
Date = Fri Dec 14 05:47:34 GMT 2012
Calendar = java.util.GregorianCalendar[time=1355464054992,areFieldsSet=true,areAllFieldsSet=true,lenient=true,

I'm sure I don't understand something but I'm stuck.
btw: my actual timezone is EST which is equivalent to GMT-05:00, but I don't understand why it displays as a
custom timezone rather than just EST. And why the calendar object and Date object both display GMT.

Thanks in advance
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46362
Welcome to the Ranch

Have a look at the TimeZone documentation. It doesn’t say anything about summer time and winter time or daylight saving time and night-time extending time. The time zone remains constant whether it is summer or winter. I know there is a database somewhere in the JRE of summer and winter times worldwide, because I keep getting messages saying it has to be updated. Remember Moscow, which ought to be several feet deep in snow now, and Cape Town, where it is almost midsummer, are in the same time zone, so summer time is not linked directly to time zones.
I don’t know much more about time zone objects, but you appear to have a couple of fields called DST_SOMETHING. You could try reading the TimeZone#toString documentation, and the documentation for this class.
I also looked at the Calendar class and the Date class and this is the only thing I found.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46362
That toString() method documentation was less helpful that I had thought!
I agree. Here's the link:
subject: Timezone won't display local
It's not a secret anymore!