Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4085909

No DST for UK time zone

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.4
    • core-libs



      Name: joT67522 Date: 10/13/97


      Now that you've (correctly) made GMT a constant timezone, you need a new zone for UK
       civil time which _does_ have DST.
      At present, a Solaris JDK 1.1.4 system seems to assume that TZ=GB-Eire means GMT, which it doesn't.

      Sample code:

      --------8<--------
      import java.util.*;
      import java.text.DateFormat;

      public class NoDST {
        public static void main(String[] args) {
          DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG,
      DateFormat.LONG);
          System.out.println(df.format(new Date()));
          df.setTimeZone(TimeZone.getDefault());
          System.out.println(df.format(new Date()));
          // This tries to implement the following lines from
          // /usr/share/lib/zoneinfo/europe:
          //# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
          //Rule GB-Eire 1981 max - Mar lastSun 1:00s 1:00 BST
          //Rule GB-Eire 1996 max - Oct lastSun 1:00s 0 GMT
          df.setTimeZone(new SimpleTimeZone(0, "GB-Eire",
      Calendar.MARCH, -1, Calendar.SUNDAY,
      3600000,
      Calendar.OCTOBER, -1, Calendar.SUNDAY,
      3600000));
          System.out.println(df.format(new Date()));
        }
      }
      --------->8--------
      Demonstration:
      ---------8<--------
      eddoe:~/tmp$ javac NoDST.java
      eddoe:~/tmp$ echo $TZ
      GB-Eire
      eddoe:~/tmp$ java NoDST
      October 13, 1997 1:01:32 PM PDT
      October 13, 1997 8:01:32 PM GMT+00:00
      October 13, 1997 9:01:32 PM GMT+01:00
      eddoe:~/tmp$ date
      Mon Oct 13 21:01:32 BST 1997
      eddoe:~/tmp$ uname -a
      SunOS eddoe 5.5 Generic sun4m sparc SUNW,SPARCstation-10
      eddoe:~/tmp$
      -------->8--------
      This also demonstrates the continued wrong-ness of the default time zone for a DateFormat,
      and what I believe to be a currently correct way of making a suitable TimeZone for the UK.


      ======================================================================

            aliusunw Alan Liu (Inactive)
            johsunw Joon Oh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: