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

CLDR timezone parsing does not work for all locales

XMLWordPrintable

    • b71
    • 9
    • b151
    • x86
    • generic

      FULL PRODUCT VERSION :
      java version "1.8.0_92"
      Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Darwin McBookAir 15.6.0 Darwin Kernel Version 15.6.0: Mon Aug 29 20:21:34 PDT 2016; root:xnu-3248.60.11~1/RELEASE_X86_64 x86_64


      A DESCRIPTION OF THE PROBLEM :
      While testing apache commons lang 3.5 on EA-9, we detected failure of timezone parsing in several locales.

      REGRESSION. Last worked in version 8u102

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compiling and running apache commons lang test suite.
      See https://issues.apache.org/jira/browse/LANG-1265

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Unit test should pass

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Run following unit test:
      j
          private static final TimeZone REYKJAVIK = TimeZone.getTimeZone("Atlantic/Reykjavik");
          private static final TimeZone NEW_YORK = TimeZone.getTimeZone("America/New_York");
          private static final TimeZone GMT = TimeZone.getTimeZone("GMT");

          @Test
          public void testTzParses() throws Exception {
              // Check that all Locales can parse the time formats we use
              for(final Locale locale : Locale.getAvailableLocales()) {
                  final SimpleDateFormat sdf= new SimpleDateFormat("yyyy/MM/dd z", locale);

                  for(final TimeZone tz : new TimeZone[]{NEW_YORK, REYKJAVIK, GMT}) {
                      final Calendar cal= Calendar.getInstance(tz, locale);
                      cal.clear();
                      cal.set(Calendar.YEAR, 2000);
                      cal.set(Calendar.MONTH, 1);
                      cal.set(Calendar.DAY_OF_MONTH, 10);
                      cal.setTimeZone(tz);
                      final Date expected= cal.getTime();

                      final Date actual = sdf.parse("2000/02/10 "+tz.getDisplayName(locale));
                      Assert.assertEquals("tz:"+tz.getID()+" locale:"+locale.getDisplayName(), expected, actual);
                  }
              }
          }
      ---------- END SOURCE ----------

            rgoel Rachna Goel (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: