< prev index next >
test/jdk/java/time/test/java/time/format/TestDateTimeFormatterBuilderWithLocale.java
Print this page
rev 51829 : imported patch 8210633
@@ -72,10 +72,11 @@
import java.time.chrono.MinguoChronology;
import java.time.chrono.ThaiBuddhistChronology;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.format.FormatStyle;
+import java.time.format.ResolverStyle;
import java.time.LocalDate;
import java.time.temporal.ChronoField;
import java.time.temporal.Temporal;
import java.util.HashMap;
@@ -132,16 +133,20 @@
}
@Test(dataProvider="mapTextLookup")
public void test_appendText_mapTextLookup(ChronoLocalDate date, Locale locale) {
final String new1st = "1st";
+ final long firstYear = 1L;
Map<Long, String> yearMap = new HashMap<>();
- yearMap.put(1L, new1st);
+ yearMap.put(firstYear, new1st);
builder.appendText(ChronoField.YEAR_OF_ERA, yearMap);
+ DateTimeFormatter formatter = builder
+ .toFormatter(locale)
+ .withResolverStyle(ResolverStyle.STRICT);
- String actual = date.format(builder.toFormatter(locale));
- assertEquals(actual, new1st);
+ assertEquals(date.format(formatter), new1st);
+ assertEquals(formatter.parse(new1st).getLong(ChronoField.YEAR_OF_ERA), firstYear);
}
//-----------------------------------------------------------------------
@DataProvider(name="localePatterns")
< prev index next >