[11] RFR: 8042131: DateTimeFormatterBuilder Mapped-values do not work for JapaneseDate
Naoto Sato
naoto.sato at oracle.com
Fri Jun 15 22:14:47 UTC 2018
Hello,
Please review the fix to the following issue:
https://bugs.openjdk.java.net/browse/JDK-8042131
The proposed change is located at:
http://cr.openjdk.java.net/~naoto/8042131/webrev.00/
The fix is originally contributedy by Toshio Nakamura at IBM [1]. I am
sponsoring the fix, with some trivial modifications to the test (diff is
attached).
Naoto
[1]
http://mail.openjdk.java.net/pipermail/core-libs-dev/2018-June/053830.html
-------------- next part --------------
diff -r 9b997bfc60d5 test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilderWithLocale.java
--- a/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilderWithLocale.java
+++ b/test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilderWithLocale.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -64,24 +64,23 @@
*/
package test.java.time.format;
+import java.time.chrono.ChronoLocalDate;
import java.time.chrono.Chronology;
import java.time.chrono.IsoChronology;
import java.time.chrono.JapaneseChronology;
import java.time.chrono.JapaneseEra;
import java.time.chrono.MinguoChronology;
import java.time.chrono.ThaiBuddhistChronology;
-import java.time.chrono.ChronoLocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.format.FormatStyle;
import java.time.LocalDate;
+import java.time.temporal.ChronoField;
import java.time.temporal.Temporal;
-import java.time.temporal.ChronoField;
-import static java.time.temporal.ChronoUnit.YEARS;
+import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
-import java.util.HashMap;
import static org.testng.Assert.assertEquals;
@@ -122,23 +121,21 @@
}
//-----------------------------------------------------------------------
- @DataProvider(name="mappedPatterns")
- Object[][] localizedMappedPatterns() {
+ @DataProvider(name="mapTextLookup")
+ Object[][] data_mapTextLookup() {
return new Object[][] {
{IsoChronology.INSTANCE.date(1,1,1), Locale.ENGLISH},
- {JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI,
- 1,1,8), Locale.ENGLISH},
+ {JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 1, 1, 8), Locale.ENGLISH},
{MinguoChronology.INSTANCE.date(1,1,1), Locale.ENGLISH},
{ThaiBuddhistChronology.INSTANCE.date(1,1,1), Locale.ENGLISH},
};
}
- @Test(dataProvider="mappedPatterns")
- public void test_getLocalizedMappedPattern(ChronoLocalDate date, Locale locale) {
+ @Test(dataProvider="mapTextLookup")
+ public void test_appendText_mapTextLookup(ChronoLocalDate date, Locale locale) {
final String new1st = "1st";
Map<Long, String> yearMap = new HashMap<>();
yearMap.put(1L, new1st);
- DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
builder.appendText(ChronoField.YEAR_OF_ERA, yearMap);
String actual = date.format(builder.toFormatter(locale));
More information about the core-libs-dev
mailing list