<i18n dev> Additional infomation for JDK-8048123

Naoto Sato naoto.sato at oracle.com
Thu Jun 22 10:16:57 UTC 2017


Hi Matsushima-san,

Thank you for the further information on the issue. I attached your  
observation in the bug report. I will fix it along with the supplemental  
era's short name inconsistency.

Naoto

On 6/22/17 1:36 PM, Mitsuru Matsushima wrote:
> At the Comparison table, I added the "Supplemental Era" behavior and "Expected?" behavior.
> Japanese usually use '平' or 'H' for abbreviated name of "平成".
> Thus, I think it's useful that the both of them are usable.
> So I added the "Expected?" behavior.
> (Ah, however it seems difficult that different behavior for short form...)
> (I don't know why CLDR don't describe wide name for Japanese era and why describe wide name as abbreviated name.)
> 
> Comparison table:
> =======================================
>                    | SimpleDateFormat| DateTimeFormatter
>                    |--------|--------|--------|--------|--------
>                    | Full   | Short  | Full   | Short  | Narrow
> ------------------|--------|--------|--------|--------|--------
>   COMPAT           | 平成   | H      | 平成   | H      | H
>   CLDR             | 平成   | 平成   | 平成   | 平成   | H
>   HOST             | 平成   | 平     | 平成   | 平     | 平成
> ------------------|--------|--------|--------|--------|--------
>   Supplemental Era | NewEra | N.E    | NewEra | N.E    | N.E
> ------------------|--------|--------|--------|--------|--------
>   Expected?        | 平成   | H      | 平成   | 平     | H
> =======================================
> 
> 
> Test code:
> Execute with java.locale.provider system property.
> =======================================
> public class SupplementalEraTest2 {
> 
>      public static void main(String... args) {
>          System.out.println("java.locale.providers="
>                  + System.getProperty("java.locale.providers"));
>          // set supplemental era
>          System.setProperty(
>                  "jdk.calendar.japanese.supplemental.era",
>                  "name=NewEra,abbr=N.E,since=1546300800000");
> 
>          final int[][] dateSrcs = {
>              //{1989, 1, 7}, {1989, 1, 8}, // Heisei before and after
>              {2018, 12, 31}, {2019, 1, 1}, // NewEra before and after
>          };
> 
>          System.out.println(">>>>> SimpleDateFormat");
>          printWithSimpleDateFormat(dateSrcs);
> 
>          System.out.println(">>>>> DateTimeFormatter");
>          printWithDateTimeFormatter(dateSrcs);
>      }
> 
>      private static void printWithSimpleDateFormat(int[][] dateSrcs) {
>          final Locale jpLocale = new Locale("ja", "JP", "JP");
>          final Calendar cal = Calendar.getInstance();
>          final Date[] dates = Arrays.stream(dateSrcs)
>                  .map((int[] d) -> {  // first month is 0
>                      cal.set(d[0], d[1] - 1, d[2], 0, 0, 0);
>                      return cal.getTime();
>                  }).toArray(Date[]::new);
>          System.out.println("---Full format");
>          SimpleDateFormat fmtLong = new SimpleDateFormat(
>                  "GGGG", jpLocale);
>          Arrays.stream(dates).map(fmtLong::format).forEach(System.out::println);
>          System.out.println("---Short format");
>          SimpleDateFormat fmtShort = new SimpleDateFormat(
>                  "G", jpLocale);
>          Arrays.stream(dates).map(fmtShort::format).forEach(System.out::println);
>      }
> 
>      private static void printWithDateTimeFormatter(int[][] dateSrcs) {
>          final Locale jpLocale = new Locale("ja", "JP", "JP");
>          final LocalDate[] lDates = Arrays.stream(dateSrcs)
>                  .map((int[] d) -> LocalDate.of(d[0], d[1], d[2]))
>                  .toArray(LocalDate[]::new);
>          System.out.println("---Full format");
>          final DateTimeFormatter fmtrFull = DateTimeFormatter.ofPattern("GGGG")
>                  .withChronology(JapaneseChronology.INSTANCE).withLocale(jpLocale);
>          Arrays.stream(lDates).map(fmtrFull::format).forEach(System.out::println);
> 
>          System.out.println("---Short format");
>          DateTimeFormatter fmtrShort = DateTimeFormatter.ofPattern("G")
>                  .withChronology(JapaneseChronology.INSTANCE).withLocale(jpLocale);
>          Arrays.stream(lDates).map(fmtrShort::format).forEach(System.out::println);
> 
>          System.out.println("---Narrow format");
>          DateTimeFormatter fmtrNarrow = DateTimeFormatter.ofPattern("GGGGG")
>                  .withChronology(JapaneseChronology.INSTANCE).withLocale(jpLocale);
>          Arrays.stream(lDates).map(fmtrNarrow::format).forEach(System.out::println);
>      }
> }
> =======================================


More information about the i18n-dev mailing list