The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

DST Handling in java.util.Date

Posted by Karan Vahi on June 12, 2001 at 9:58 AM

Dear All

I am facing a problem with the way Java handles DST in Date objects.
Suppose we have 2 timezones with same GMT offset; one which has an option
of DST e.g Central Time(U.S and Canada)GMT -6:00 and other which doesn't follow DST Mexico City GMT -6:00.
If I run my sytem on MexicoCity Timezone and make a simple proram which just displays the current Date using java.util.Date class, I get the time and offset in that string
according to DST e.g I get Date displayed as Tue Jun 12 07:50:55 GMT-05:00 2001 even though the time on my system was 06:50:55 with timezone as Mexico City. So the date displayed should have been Tue Jun 12 06:50:55 GMT-06:00 2001 instead of Tue Jun 12 07:50:55 GMT-05:00 2001
I am working on Windows NT.
Please suggest a way for a correct display of dates.

The java program I ran was

import java.util.*;

public class Untitled1 {

public Untitled1() {
}

public static void main(String[] args) {
System.out.println(new Date());
}

}

Thanking You
Karan Vahi




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us