• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Timezone won't display local

 
randy reed
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],
firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2012,MONTH=11,WEEK_OF_YEAR=50,
WEEK_OF_MONTH=3,DAY_OF_MONTH=14,DAY_OF_YEAR=349,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=2,
AM_PM=0,HOUR=5,HOUR_OF_DAY=5,MINUTE=47,SECOND=34,MILLISECOND=992,ZONE_OFFSET=0,DST_OFFSET=0]

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
Randy
 
Campbell Ritchie
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That toString() method documentation was less helpful that I had thought!
 
reply
    Bookmark Topic Watch Topic
  • New Topic