• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.util.timezone issue in EST and EDT  RSS feed

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Iam trying to use java.util.timezone and I see this :


System.out.println("Time Zone : "+TimeZone.getDefault().getDisplayName());
System.out.println("Date :"+ new Date());

The output is :

Time Zone : Eastern Standard Time
Date :Tue Jun 19 09:51:48 EDT 2012


I am really confused. Why is it that a timezone in EDT is displayed as Eastern standard time by java.util.timezone? Any pointers will greatly help.

Thanks.
 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Radha Gopal wrote:I am really confused. Why is it that a timezone in EDT is displayed as Eastern standard time by java.util.timezone?

Because the timezone is called "Eastern Standard Time", but it uses Daylight Savings; and the name when displaying a time during the summer is "Eastern Daylight Time". Same timezone, different rules in the summer.

Winston
 
Radha Gopal
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Winston . Now I understand.

Is there a way to get the exact format using java.util.Timezone like when the date is EDT can I also see the display as Eastern Day Time instead of Eastern Standard time ?
 
Ranch Hand
Posts: 3090
14
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Radha Gopal
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Mike. It made everything clear as to how to convert
 
Radha Gopal
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

Following this , I am just curious to know :

Example Situation :

My JVM process is started on Friday and is up and running
On Sunday there was a day light savings change from EST to EDT.

I have the following lines of code :

TimeZone tz = TimeZone.getDefault();
String name = tz.getDisplayName(tz.inDaylightTime(new Date()), TimeZone.SHORT);

If the JVM that started on friday and is running is going to these statements on Sunday , will it give the new adjusted timezone(EDT) or will it give the old timezone(EST) since it was started on Friday?

Thanks
 
Sheriff
Posts: 22845
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are passing the current date and time (i.e. a timestamp on Sunday, not Friday) to the inDaylightTime() method. What does the documentation for that method say about that?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!