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

(tz) Introduction of tzdata2005r can introduce incompatility issues with some JDK1.1 3-letter TZ Ids

    Details

    • Subcomponent:
    • Resolved In Build:
      b38
    • CPU:
      x86, sparc
    • OS:
      solaris_10, windows_xp
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
        Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)

        and

        java version "1.6.0-beta2"
        Java(TM) SE Runtime Environment (build 1.6.0-beta2-b86)
        Java HotSpot(TM) Client VM (build 1.6.0-beta2-b86, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows XP [Version 5.1.2600]

        A DESCRIPTION OF THE PROBLEM :
        Update 08 changed the interpretation of "EST" to not include DST.

        This means that all legacy Applets and applications which used EST before are now broken.

        See the outputs from the demo program. Eastern and EST should be the same under all Java versions.
        ************************
        Time Zone Test on JVM 1.5.0_06
        Current time in EST = 8/31/06 9:42 PM
        Correct Eastern time = 8/31/06 9:42 PM
        Current time in PST = 8/31/06 6:42 PM
        Correct Pacific time = 8/31/06 6:42 PM
        EST = sun.util.calendar.ZoneInfo[id="EST",offset=-18000000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=EST,offset=-18000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]
        PST = sun.util.calendar.ZoneInfo[id="PST",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=PST,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]
        **********************************
        Time Zone Test on JVM 1.5.0_08
        Current time in EST = 8/31/06 8:42 PM
        Correct Eastern time = 8/31/06 9:42 PM
        Current time in PST = 8/31/06 6:42 PM
        Correct Pacific time = 8/31/06 6:42 PM
        EST = sun.util.calendar.ZoneInfo[id="EST",offset=-18000000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]
        PST = sun.util.calendar.ZoneInfo[id="PST",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=PST,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]
        *********************************
        Time Zone Test on JVM 1.6.0-beta2
        Current time in EST = 8/31/06 8:43 PM
        Correct Eastern time = 8/31/06 9:43 PM
        Current time in PST = 8/31/06 6:43 PM
        Correct Pacific time = 8/31/06 6:43 PM
        EST = sun.util.calendar.ZoneInfo[id="EST",offset=-18000000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]
        PST = sun.util.calendar.ZoneInfo[id="PST",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=PST,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the following code under different versions of Java and see the results.

        Run under 1.5.0_06
        Run under 1.5.0_08
        Run under 1.6 beta 2

        public class TimeUtil {

        private static TimeZone PACIFIC = null;
        private static TimeZone EASTERN = null;

        /**
        * Getting eastern daylight savings time in a way that returns a valid time zone for JDK 1.1 and
        * all later versions.
        * @return Eastern time
        */
        public static TimeZone getEastern() {
        if (EASTERN == null) {
        EASTERN = chooseTimeZone(new String[] { "America/New_York", "EST5EDT", "EST" });
        }
        return EASTERN;
        }

        /**
        * Getting pacific daylight savings time in a way that returns a valid time zone for JDK 1.1 and
        * all later versions.
        * @return Pacific time
        */
        public static TimeZone getPacific() {
        if (PACIFIC == null) {
        PACIFIC = chooseTimeZone(new String[] { "America/Los_Angeles", "PST8PDT", "PST" });
        }
        return PACIFIC;
        }

        private static TimeZone chooseTimeZone(String[] preferredChoices) {
        boolean[] availableChoices = new boolean[preferredChoices.length];
        for (int i = 0; i < availableChoices.length; i++) {
        availableChoices[i] = false;
        }
        String[] tz = TimeZone.getAvailableIDs();
        for (int i = 0; i < tz.length; i++) {
        String zoneName = tz[i];
        //System.out.println("checking: "+zoneName);
        for (int j = 0; j < preferredChoices.length; j++) {
        if (zoneName.equals(preferredChoices[j])) {
        availableChoices[j] = true;
        }
        }
        }
        for (int i = 0; i < availableChoices.length; i++) {
        if (availableChoices[i]) {
        //System.out.println("Using "+preferredChoices[i]);
        return TimeZone.getTimeZone(preferredChoices[i]);
        }
        }
        return null;
        }

        /**/
        // Test the time zones on current VM
        public static void main(String[] args) {
        System.out.println("Time Zone Test on JVM "+ System.getProperty("java.version"));
        DateFormat fmt = new SimpleDateFormat();

        Date date = new Date();
        fmt.setTimeZone(TimeZone.getTimeZone("EST"));
        System.out.println("Current time in EST = "+fmt.format(date));
        fmt.setTimeZone(getEastern());
        System.out.println("Correct Eastern time = "+fmt.format(date));

        fmt.setTimeZone(TimeZone.getTimeZone("PST"));
        System.out.println("Current time in PST = "+fmt.format(date));
        fmt.setTimeZone(getPacific());
        System.out.println("Correct Pacific time = "+fmt.format(date));

        System.out.println("EST = "+TimeZone.getTimeZone("EST"));
        System.out.println("PST = "+TimeZone.getTimeZone("PST"));
        }
        /**/

        }

        Outputs:
        ************************
        Time Zone Test on JVM 1.5.0_06
        Current time in EST = 8/31/06 9:42 PM
        Correct Eastern time = 8/31/06 9:42 PM
        Current time in PST = 8/31/06 6:42 PM
        Correct Pacific time = 8/31/06 6:42 PM
        EST = sun.util.calendar.ZoneInfo[id="EST",offset=-18000000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=EST,offset=-18000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]
        PST = sun.util.calendar.ZoneInfo[id="PST",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=PST,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]
        **********************************
        Time Zone Test on JVM 1.5.0_08
        Current time in EST = 8/31/06 8:42 PM
        Correct Eastern time = 8/31/06 9:42 PM
        Current time in PST = 8/31/06 6:42 PM
        Correct Pacific time = 8/31/06 6:42 PM
        EST = sun.util.calendar.ZoneInfo[id="EST",offset=-18000000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]
        PST = sun.util.calendar.ZoneInfo[id="PST",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=PST,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]
        *********************************
        Time Zone Test on JVM 1.6.0-beta2
        Current time in EST = 8/31/06 8:43 PM
        Correct Eastern time = 8/31/06 9:43 PM
        Current time in PST = 8/31/06 6:43 PM
        Correct Pacific time = 8/31/06 6:43 PM
        EST = sun.util.calendar.ZoneInfo[id="EST",offset=-18000000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]
        PST = sun.util.calendar.ZoneInfo[id="PST",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=PST,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]



        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Expected:

        EST and Eastern time are always the same
        ACTUAL -
        EST is one hour offset from Eastern time

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        public class TimeUtil {

        private static TimeZone PACIFIC = null;
        private static TimeZone EASTERN = null;

        /**
        * Getting eastern daylight savings time in a way that returns a valid time zone for JDK 1.1 and
        * all later versions.
        * @return Eastern time
        */
        public static TimeZone getEastern() {
        if (EASTERN == null) {
        EASTERN = chooseTimeZone(new String[] { "America/New_York", "EST5EDT", "EST" });
        }
        return EASTERN;
        }

        /**
        * Getting pacific daylight savings time in a way that returns a valid time zone for JDK 1.1 and
        * all later versions.
        * @return Pacific time
        */
        public static TimeZone getPacific() {
        if (PACIFIC == null) {
        PACIFIC = chooseTimeZone(new String[] { "America/Los_Angeles", "PST8PDT", "PST" });
        }
        return PACIFIC;
        }

        private static TimeZone chooseTimeZone(String[] preferredChoices) {
        boolean[] availableChoices = new boolean[preferredChoices.length];
        for (int i = 0; i < availableChoices.length; i++) {
        availableChoices[i] = false;
        }
        String[] tz = TimeZone.getAvailableIDs();
        for (int i = 0; i < tz.length; i++) {
        String zoneName = tz[i];
        //System.out.println("checking: "+zoneName);
        for (int j = 0; j < preferredChoices.length; j++) {
        if (zoneName.equals(preferredChoices[j])) {
        availableChoices[j] = true;
        }
        }
        }
        for (int i = 0; i < availableChoices.length; i++) {
        if (availableChoices[i]) {
        //System.out.println("Using "+preferredChoices[i]);
        return TimeZone.getTimeZone(preferredChoices[i]);
        }
        }
        return null;
        }

        /**/
        // Test the time zones on current VM
        public static void main(String[] args) {
        System.out.println("Time Zone Test on JVM "+ System.getProperty("java.version"));
        DateFormat fmt = new SimpleDateFormat();

        Date date = new Date();
        fmt.setTimeZone(TimeZone.getTimeZone("EST"));
        System.out.println("Current time in EST = "+fmt.format(date));
        fmt.setTimeZone(getEastern());
        System.out.println("Correct Eastern time = "+fmt.format(date));

        fmt.setTimeZone(TimeZone.getTimeZone("PST"));
        System.out.println("Current time in PST = "+fmt.format(date));
        fmt.setTimeZone(getPacific());
        System.out.println("Correct Pacific time = "+fmt.format(date));

        System.out.println("EST = "+TimeZone.getTimeZone("EST"));
        System.out.println("PST = "+TimeZone.getTimeZone("PST"));
        }
        /**/

        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        No workaround.

        Release Regression From : 5.0u6
        The above release value was the last known release where this
        bug was not reproducible. Since then there has been a regression.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  peytoia Yuka Kamiya (Inactive)
                  Reporter:
                  ndcosta Nelson Dcosta (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: