test/java/time/tck/java/time/format/TCKDateTimeFormatters.java

Print this page

        

@@ -72,41 +72,37 @@
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
 
 import java.text.ParsePosition;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
 import java.time.DateTimeException;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.Year;
+import java.time.YearMonth;
 import java.time.ZoneId;
 import java.time.ZoneOffset;
 import java.time.ZonedDateTime;
-import java.time.format.DateTimeBuilder;
+import java.time.chrono.Chronology;
 import java.time.format.DateTimeFormatter;
-import java.time.format.DateTimeFormatters;
 import java.time.format.DateTimeParseException;
-import java.time.format.DateTimePrintException;
-import java.time.temporal.ISOFields;
+import java.time.temporal.IsoFields;
 import java.time.temporal.Queries;
 import java.time.temporal.TemporalAccessor;
 import java.time.temporal.TemporalField;
 import java.time.temporal.TemporalQuery;
-import java.time.temporal.Year;
-import java.time.temporal.YearMonth;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
 
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 /**
- * Test DateTimeFormatters.
+ * Test DateTimeFormatter.
  */
 @Test
 public class TCKDateTimeFormatters {
 
     @BeforeMethod

@@ -114,56 +110,56 @@
     }
 
     //-----------------------------------------------------------------------
     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
     public void test_print_nullCalendrical() {
-        DateTimeFormatters.isoDate().print((TemporalAccessor) null);
+        DateTimeFormatter.ISO_DATE.format((TemporalAccessor) null);
     }
 
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     @Test(groups={"tck"})
     public void test_pattern_String() {
-        DateTimeFormatter test = DateTimeFormatters.pattern("d MMM yyyy");
+        DateTimeFormatter test = DateTimeFormatter.ofPattern("d MMM yyyy");
         assertEquals(test.toString(), "Value(DayOfMonth)' 'Text(MonthOfYear,SHORT)' 'Value(Year,4,19,EXCEEDS_PAD)");
         assertEquals(test.getLocale(), Locale.getDefault());
     }
 
     @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"})
     public void test_pattern_String_invalid() {
-        DateTimeFormatters.pattern("p");
+        DateTimeFormatter.ofPattern("p");
     }
 
     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
     public void test_pattern_String_null() {
-        DateTimeFormatters.pattern(null);
+        DateTimeFormatter.ofPattern(null);
     }
 
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     @Test(groups={"tck"})
     public void test_pattern_StringLocale() {
-        DateTimeFormatter test = DateTimeFormatters.pattern("d MMM yyyy", Locale.UK);
+        DateTimeFormatter test = DateTimeFormatter.ofPattern("d MMM yyyy", Locale.UK);
         assertEquals(test.toString(), "Value(DayOfMonth)' 'Text(MonthOfYear,SHORT)' 'Value(Year,4,19,EXCEEDS_PAD)");
         assertEquals(test.getLocale(), Locale.UK);
     }
 
     @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"})
     public void test_pattern_StringLocale_invalid() {
-        DateTimeFormatters.pattern("p", Locale.UK);
+        DateTimeFormatter.ofPattern("p", Locale.UK);
     }
 
     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
     public void test_pattern_StringLocale_nullPattern() {
-        DateTimeFormatters.pattern(null, Locale.UK);
+        DateTimeFormatter.ofPattern(null, Locale.UK);
     }
 
     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
     public void test_pattern_StringLocale_nullLocale() {
-        DateTimeFormatters.pattern("yyyy", null);
+        DateTimeFormatter.ofPattern("yyyy", null);
     }
 
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------

@@ -191,14 +187,14 @@
     public void test_print_isoLocalDate(
             Integer year, Integer month, Integer day, String offsetId, String zoneId,
             String expected, Class<?> expectedEx) {
         TemporalAccessor test = buildAccessor(year, month, day, null, null, null, null, offsetId, zoneId);
         if (expectedEx == null) {
-            assertEquals(DateTimeFormatters.isoLocalDate().print(test), expected);
+            assertEquals(DateTimeFormatter.ISO_LOCAL_DATE.format(test), expected);
         } else {
             try {
-                DateTimeFormatters.isoLocalDate().print(test);
+                DateTimeFormatter.ISO_LOCAL_DATE.format(test);
                 fail();
             } catch (Exception ex) {
                 assertTrue(expectedEx.isInstance(ex));
             }
         }

@@ -207,45 +203,45 @@
     @Test(dataProvider="sample_isoLocalDate", groups={"tck"})
     public void test_parse_isoLocalDate(
             Integer year, Integer month, Integer day, String offsetId, String zoneId,
             String input, Class<?> invalid) {
         if (input != null) {
-            DateTimeBuilder expected = createDate(year, month, day);
+            Expected expected = createDate(year, month, day);
             // offset/zone not expected to be parsed
-            assertParseMatch(DateTimeFormatters.isoLocalDate().parseToBuilder(input, new ParsePosition(0)), expected);
+            assertParseMatch(DateTimeFormatter.ISO_LOCAL_DATE.parseUnresolved(input, new ParsePosition(0)), expected);
         }
     }
 
     @Test(groups={"tck"})
     public void test_parse_isoLocalDate_999999999() {
-        DateTimeBuilder expected = createDate(999999999, 8, 6);
-        assertParseMatch(DateTimeFormatters.isoLocalDate().parseToBuilder("+999999999-08-06", new ParsePosition(0)), expected);
+        Expected expected = createDate(999999999, 8, 6);
+        assertParseMatch(DateTimeFormatter.ISO_LOCAL_DATE.parseUnresolved("+999999999-08-06", new ParsePosition(0)), expected);
         assertEquals(LocalDate.parse("+999999999-08-06"), LocalDate.of(999999999, 8, 6));
     }
 
     @Test(groups={"tck"})
     public void test_parse_isoLocalDate_1000000000() {
-        DateTimeBuilder expected = createDate(1000000000, 8, 6);
-        assertParseMatch(DateTimeFormatters.isoLocalDate().parseToBuilder("+1000000000-08-06", new ParsePosition(0)), expected);
+        Expected expected = createDate(1000000000, 8, 6);
+        assertParseMatch(DateTimeFormatter.ISO_LOCAL_DATE.parseUnresolved("+1000000000-08-06", new ParsePosition(0)), expected);
     }
 
     @Test(expectedExceptions = DateTimeException.class, groups={"tck"})
     public void test_parse_isoLocalDate_1000000000_failedCreate() {
         LocalDate.parse("+1000000000-08-06");
     }
 
     @Test(groups={"tck"})
     public void test_parse_isoLocalDate_M999999999() {
-        DateTimeBuilder expected = createDate(-999999999, 8, 6);
-        assertParseMatch(DateTimeFormatters.isoLocalDate().parseToBuilder("-999999999-08-06", new ParsePosition(0)), expected);
+        Expected expected = createDate(-999999999, 8, 6);
+        assertParseMatch(DateTimeFormatter.ISO_LOCAL_DATE.parseUnresolved("-999999999-08-06", new ParsePosition(0)), expected);
         assertEquals(LocalDate.parse("-999999999-08-06"), LocalDate.of(-999999999, 8, 6));
     }
 
     @Test(groups={"tck"})
     public void test_parse_isoLocalDate_M1000000000() {
-        DateTimeBuilder expected = createDate(-1000000000, 8, 6);
-        assertParseMatch(DateTimeFormatters.isoLocalDate().parseToBuilder("-1000000000-08-06", new ParsePosition(0)), expected);
+        Expected expected = createDate(-1000000000, 8, 6);
+        assertParseMatch(DateTimeFormatter.ISO_LOCAL_DATE.parseUnresolved("-1000000000-08-06", new ParsePosition(0)), expected);
     }
 
     @Test(expectedExceptions = DateTimeException.class, groups={"tck"})
     public void test_parse_isoLocalDate_M1000000000_failedCreate() {
         LocalDate.parse("-1000000000-08-06");

@@ -278,14 +274,14 @@
     public void test_print_isoOffsetDate(
             Integer year, Integer month, Integer day, String offsetId, String zoneId,
             String expected, Class<?> expectedEx) {
         TemporalAccessor test = buildAccessor(year, month, day, null, null, null, null, offsetId, zoneId);
         if (expectedEx == null) {
-            assertEquals(DateTimeFormatters.isoOffsetDate().print(test), expected);
+            assertEquals(DateTimeFormatter.ISO_OFFSET_DATE.format(test), expected);
         } else {
             try {
-                DateTimeFormatters.isoOffsetDate().print(test);
+                DateTimeFormatter.ISO_OFFSET_DATE.format(test);
                 fail();
             } catch (Exception ex) {
                 assertTrue(expectedEx.isInstance(ex));
             }
         }

@@ -294,13 +290,13 @@
     @Test(dataProvider="sample_isoOffsetDate", groups={"tck"})
     public void test_parse_isoOffsetDate(
             Integer year, Integer month, Integer day, String offsetId, String zoneId,
             String input, Class<?> invalid) {
         if (input != null) {
-            DateTimeBuilder expected = createDate(year, month, day);
+            Expected expected = createDate(year, month, day);
             buildCalendrical(expected, offsetId, null);  // zone not expected to be parsed
-            assertParseMatch(DateTimeFormatters.isoOffsetDate().parseToBuilder(input, new ParsePosition(0)), expected);
+            assertParseMatch(DateTimeFormatter.ISO_OFFSET_DATE.parseUnresolved(input, new ParsePosition(0)), expected);
         }
     }
 
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------

@@ -329,14 +325,14 @@
     public void test_print_isoDate(
             Integer year, Integer month, Integer day, String offsetId, String zoneId,
             String expected, Class<?> expectedEx) {
         TemporalAccessor test = buildAccessor(year, month, day, null, null, null, null, offsetId, zoneId);
         if (expectedEx == null) {
-            assertEquals(DateTimeFormatters.isoDate().print(test), expected);
+            assertEquals(DateTimeFormatter.ISO_DATE.format(test), expected);
         } else {
             try {
-                DateTimeFormatters.isoDate().print(test);
+                DateTimeFormatter.ISO_DATE.format(test);
                 fail();
             } catch (Exception ex) {
                 assertTrue(expectedEx.isInstance(ex));
             }
         }

@@ -345,15 +341,15 @@
     @Test(dataProvider="sample_isoDate", groups={"tck"})
     public void test_parse_isoDate(
             Integer year, Integer month, Integer day, String offsetId, String zoneId,
             String input, Class<?> invalid) {
         if (input != null) {
-            DateTimeBuilder expected = createDate(year, month, day);
+            Expected expected = createDate(year, month, day);
             if (offsetId != null) {
-                expected.addFieldValue(OFFSET_SECONDS, ZoneOffset.of(offsetId).getTotalSeconds());
+                expected.add(ZoneOffset.of(offsetId));
             }
-            assertParseMatch(DateTimeFormatters.isoDate().parseToBuilder(input, new ParsePosition(0)), expected);
+            assertParseMatch(DateTimeFormatter.ISO_DATE.parseUnresolved(input, new ParsePosition(0)), expected);
         }
     }
 
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------

@@ -394,14 +390,14 @@
     public void test_print_isoLocalTime(
             Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId,
             String expected, Class<?> expectedEx) {
         TemporalAccessor test = buildAccessor(null, null, null, hour, min, sec, nano, offsetId, zoneId);
         if (expectedEx == null) {
-            assertEquals(DateTimeFormatters.isoLocalTime().print(test), expected);
+            assertEquals(DateTimeFormatter.ISO_LOCAL_TIME.format(test), expected);
         } else {
             try {
-                DateTimeFormatters.isoLocalTime().print(test);
+                DateTimeFormatter.ISO_LOCAL_TIME.format(test);
                 fail();
             } catch (Exception ex) {
                 assertTrue(expectedEx.isInstance(ex));
             }
         }

@@ -410,13 +406,13 @@
     @Test(dataProvider="sample_isoLocalTime", groups={"tck"})
     public void test_parse_isoLocalTime(
             Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId,
             String input, Class<?> invalid) {
         if (input != null) {
-            DateTimeBuilder expected = createTime(hour, min, sec, nano);
+            Expected expected = createTime(hour, min, sec, nano);
             // offset/zone not expected to be parsed
-            assertParseMatch(DateTimeFormatters.isoLocalTime().parseToBuilder(input, new ParsePosition(0)), expected);
+            assertParseMatch(DateTimeFormatter.ISO_LOCAL_TIME.parseUnresolved(input, new ParsePosition(0)), expected);
         }
     }
 
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------

@@ -457,14 +453,14 @@
     public void test_print_isoOffsetTime(
             Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId,
             String expected, Class<?> expectedEx) {
         TemporalAccessor test = buildAccessor(null, null, null, hour, min, sec, nano, offsetId, zoneId);
         if (expectedEx == null) {
-            assertEquals(DateTimeFormatters.isoOffsetTime().print(test), expected);
+            assertEquals(DateTimeFormatter.ISO_OFFSET_TIME.format(test), expected);
         } else {
             try {
-                DateTimeFormatters.isoOffsetTime().print(test);
+                DateTimeFormatter.ISO_OFFSET_TIME.format(test);
                 fail();
             } catch (Exception ex) {
                 assertTrue(expectedEx.isInstance(ex));
             }
         }

@@ -473,13 +469,13 @@
     @Test(dataProvider="sample_isoOffsetTime", groups={"tck"})
     public void test_parse_isoOffsetTime(
             Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId,
             String input, Class<?> invalid) {
         if (input != null) {
-            DateTimeBuilder expected = createTime(hour, min, sec, nano);
+            Expected expected = createTime(hour, min, sec, nano);
             buildCalendrical(expected, offsetId, null);  // zoneId is not expected from parse
-            assertParseMatch(DateTimeFormatters.isoOffsetTime().parseToBuilder(input, new ParsePosition(0)), expected);
+            assertParseMatch(DateTimeFormatter.ISO_OFFSET_TIME.parseUnresolved(input, new ParsePosition(0)), expected);
         }
     }
 
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------

@@ -520,14 +516,14 @@
     public void test_print_isoTime(
             Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId,
             String expected, Class<?> expectedEx) {
         TemporalAccessor test = buildAccessor(null, null, null, hour, min, sec, nano, offsetId, zoneId);
         if (expectedEx == null) {
-            assertEquals(DateTimeFormatters.isoTime().print(test), expected);
+            assertEquals(DateTimeFormatter.ISO_TIME.format(test), expected);
         } else {
             try {
-                DateTimeFormatters.isoTime().print(test);
+                DateTimeFormatter.ISO_TIME.format(test);
                 fail();
             } catch (Exception ex) {
                 assertTrue(expectedEx.isInstance(ex));
             }
         }

@@ -536,15 +532,15 @@
     @Test(dataProvider="sample_isoTime", groups={"tck"})
     public void test_parse_isoTime(
             Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId,
             String input, Class<?> invalid) {
         if (input != null) {
-            DateTimeBuilder expected = createTime(hour, min, sec, nano);
+            Expected expected = createTime(hour, min, sec, nano);
             if (offsetId != null) {
-                expected.addFieldValue(OFFSET_SECONDS, ZoneOffset.of(offsetId).getTotalSeconds());
+                expected.add(ZoneOffset.of(offsetId));
             }
-            assertParseMatch(DateTimeFormatters.isoTime().parseToBuilder(input, new ParsePosition(0)), expected);
+            assertParseMatch(DateTimeFormatter.ISO_TIME.parseUnresolved(input, new ParsePosition(0)), expected);
         }
     }
 
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------

@@ -594,14 +590,14 @@
             Integer year, Integer month, Integer day,
             Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId,
             String expected, Class<?> expectedEx) {
         TemporalAccessor test = buildAccessor(year, month, day, hour, min, sec, nano, offsetId, zoneId);
         if (expectedEx == null) {
-            assertEquals(DateTimeFormatters.isoLocalDateTime().print(test), expected);
+            assertEquals(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(test), expected);
         } else {
             try {
-                DateTimeFormatters.isoLocalDateTime().print(test);
+                DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(test);
                 fail();
             } catch (Exception ex) {
                 assertTrue(expectedEx.isInstance(ex));
             }
         }

@@ -611,12 +607,12 @@
     public void test_parse_isoLocalDateTime(
             Integer year, Integer month, Integer day,
             Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId,
             String input, Class<?> invalid) {
         if (input != null) {
-            DateTimeBuilder expected = createDateTime(year, month, day, hour, min, sec, nano);
-            assertParseMatch(DateTimeFormatters.isoLocalDateTime().parseToBuilder(input, new ParsePosition(0)), expected);
+            Expected expected = createDateTime(year, month, day, hour, min, sec, nano);
+            assertParseMatch(DateTimeFormatter.ISO_LOCAL_DATE_TIME.parseUnresolved(input, new ParsePosition(0)), expected);
         }
     }
 
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------

@@ -666,14 +662,14 @@
             Integer year, Integer month, Integer day,
             Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId,
             String expected, Class<?> expectedEx) {
         TemporalAccessor test = buildAccessor(year, month, day, hour, min, sec, nano, offsetId, zoneId);
         if (expectedEx == null) {
-            assertEquals(DateTimeFormatters.isoOffsetDateTime().print(test), expected);
+            assertEquals(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(test), expected);
         } else {
             try {
-                DateTimeFormatters.isoOffsetDateTime().print(test);
+                DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(test);
                 fail();
             } catch (Exception ex) {
                 assertTrue(expectedEx.isInstance(ex));
             }
         }

@@ -683,13 +679,13 @@
     public void test_parse_isoOffsetDateTime(
             Integer year, Integer month, Integer day,
             Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId,
             String input, Class<?> invalid) {
         if (input != null) {
-            DateTimeBuilder expected = createDateTime(year, month, day, hour, min, sec, nano);
+            Expected expected = createDateTime(year, month, day, hour, min, sec, nano);
             buildCalendrical(expected, offsetId, null);  // zone not expected to be parsed
-            assertParseMatch(DateTimeFormatters.isoOffsetDateTime().parseToBuilder(input, new ParsePosition(0)), expected);
+            assertParseMatch(DateTimeFormatter.ISO_OFFSET_DATE_TIME.parseUnresolved(input, new ParsePosition(0)), expected);
         }
     }
 
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------

@@ -748,14 +744,14 @@
             Integer year, Integer month, Integer day,
             Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId,
             String expected, Class<?> expectedEx) {
         TemporalAccessor test = buildAccessor(year, month, day, hour, min, sec, nano, offsetId, zoneId);
         if (expectedEx == null) {
-            assertEquals(DateTimeFormatters.isoZonedDateTime().print(test), expected);
+            assertEquals(DateTimeFormatter.ISO_ZONED_DATE_TIME.format(test), expected);
         } else {
             try {
-                DateTimeFormatters.isoZonedDateTime().print(test);
+                DateTimeFormatter.ISO_ZONED_DATE_TIME.format(test);
                 fail(test.toString());
             } catch (Exception ex) {
                 assertTrue(expectedEx.isInstance(ex));
             }
         }

@@ -765,17 +761,17 @@
     public void test_parse_isoZonedDateTime(
             Integer year, Integer month, Integer day,
             Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId,
             String input, Class<?> invalid) {
         if (input != null) {
-            DateTimeBuilder expected = createDateTime(year, month, day, hour, min, sec, nano);
+            Expected expected = createDateTime(year, month, day, hour, min, sec, nano);
             if (offsetId.equals(zoneId)) {
                 buildCalendrical(expected, offsetId, null);
             } else {
                 buildCalendrical(expected, offsetId, zoneId);
             }
-            assertParseMatch(DateTimeFormatters.isoZonedDateTime().parseToBuilder(input, new ParsePosition(0)), expected);
+            assertParseMatch(DateTimeFormatter.ISO_ZONED_DATE_TIME.parseUnresolved(input, new ParsePosition(0)), expected);
         }
     }
 
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------

@@ -825,14 +821,14 @@
             Integer year, Integer month, Integer day,
             Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId,
             String expected, Class<?> expectedEx) {
         TemporalAccessor test = buildAccessor(year, month, day, hour, min, sec, nano, offsetId, zoneId);
         if (expectedEx == null) {
-            assertEquals(DateTimeFormatters.isoDateTime().print(test), expected);
+            assertEquals(DateTimeFormatter.ISO_DATE_TIME.format(test), expected);
         } else {
             try {
-                DateTimeFormatters.isoDateTime().print(test);
+                DateTimeFormatter.ISO_DATE_TIME.format(test);
                 fail();
             } catch (Exception ex) {
                 assertTrue(expectedEx.isInstance(ex));
             }
         }

@@ -842,124 +838,140 @@
     public void test_parse_isoDateTime(
             Integer year, Integer month, Integer day,
             Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId,
             String input, Class<?> invalid) {
         if (input != null) {
-            DateTimeBuilder expected = createDateTime(year, month, day, hour, min, sec, nano);
+            Expected expected = createDateTime(year, month, day, hour, min, sec, nano);
             if (offsetId != null) {
-                expected.addFieldValue(OFFSET_SECONDS, ZoneOffset.of(offsetId).getTotalSeconds());
+                expected.add(ZoneOffset.of(offsetId));
                 if (zoneId != null) {
-                    expected.addCalendrical(ZoneId.of(zoneId));
+                    expected.zone = ZoneId.of(zoneId);
                 }
             }
-            assertParseMatch(DateTimeFormatters.isoDateTime().parseToBuilder(input, new ParsePosition(0)), expected);
+            assertParseMatch(DateTimeFormatter.ISO_DATE_TIME.parseUnresolved(input, new ParsePosition(0)), expected);
         }
     }
 
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     @Test(groups={"tck"})
     public void test_print_isoOrdinalDate() {
         TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), null, null);
-        assertEquals(DateTimeFormatters.isoOrdinalDate().print(test), "2008-155");
+        assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.format(test), "2008-155");
     }
 
     @Test(groups={"tck"})
     public void test_print_isoOrdinalDate_offset() {
         TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), "Z", null);
-        assertEquals(DateTimeFormatters.isoOrdinalDate().print(test), "2008-155Z");
+        assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.format(test), "2008-155Z");
     }
 
     @Test(groups={"tck"})
     public void test_print_isoOrdinalDate_zoned() {
         TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), "+02:00", "Europe/Paris");
-        assertEquals(DateTimeFormatters.isoOrdinalDate().print(test), "2008-155+02:00");
+        assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.format(test), "2008-155+02:00");
     }
 
     @Test(groups={"tck"})
     public void test_print_isoOrdinalDate_zoned_largeYear() {
         TemporalAccessor test = buildAccessor(LocalDateTime.of(123456, 6, 3, 11, 5, 30), "Z", null);
-        assertEquals(DateTimeFormatters.isoOrdinalDate().print(test), "+123456-155Z");
+        assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.format(test), "+123456-155Z");
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_print_isoOrdinalDate_fields() {
-        TemporalAccessor test = new DateTimeBuilder(YEAR, 2008).addFieldValue(DAY_OF_YEAR, 231);
-        assertEquals(DateTimeFormatters.isoOrdinalDate().print(test), "2008-231");
+        // mock for testing that does not fully comply with TemporalAccessor contract
+        TemporalAccessor test = new TemporalAccessor() {
+            @Override
+            public boolean isSupported(TemporalField field) {
+                return field == YEAR || field == DAY_OF_YEAR;
+            }
+            @Override
+            public long getLong(TemporalField field) {
+                if (field == YEAR) {
+                    return 2008;
+                }
+                if (field == DAY_OF_YEAR) {
+                    return 231;
+                }
+                throw new DateTimeException("Unsupported");
+            }
+        };
+        assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.format(test), "2008-231");
     }
 
-    @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeException.class)
     public void test_print_isoOrdinalDate_missingField() {
         TemporalAccessor test = Year.of(2008);
-        DateTimeFormatters.isoOrdinalDate().print(test);
+        DateTimeFormatter.ISO_ORDINAL_DATE.format(test);
     }
 
     //-----------------------------------------------------------------------
     @Test(groups={"tck"})
     public void test_parse_isoOrdinalDate() {
-        DateTimeBuilder expected = new DateTimeBuilder(YEAR, 2008).addFieldValue(DAY_OF_YEAR, 123);
-        assertParseMatch(DateTimeFormatters.isoOrdinalDate().parseToBuilder("2008-123", new ParsePosition(0)), expected);
+        Expected expected = new Expected(YEAR, 2008, DAY_OF_YEAR, 123);
+        assertParseMatch(DateTimeFormatter.ISO_ORDINAL_DATE.parseUnresolved("2008-123", new ParsePosition(0)), expected);
     }
 
     @Test(groups={"tck"})
     public void test_parse_isoOrdinalDate_largeYear() {
-        DateTimeBuilder expected = new DateTimeBuilder(YEAR, 123456).addFieldValue(DAY_OF_YEAR, 123);
-        assertParseMatch(DateTimeFormatters.isoOrdinalDate().parseToBuilder("+123456-123", new ParsePosition(0)), expected);
+        Expected expected = new Expected(YEAR, 123456, DAY_OF_YEAR, 123);
+        assertParseMatch(DateTimeFormatter.ISO_ORDINAL_DATE.parseUnresolved("+123456-123", new ParsePosition(0)), expected);
     }
 
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     @Test(groups={"tck"})
     public void test_print_basicIsoDate() {
         TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), null, null);
-        assertEquals(DateTimeFormatters.basicIsoDate().print(test), "20080603");
+        assertEquals(DateTimeFormatter.BASIC_ISO_DATE.format(test), "20080603");
     }
 
     @Test(groups={"tck"})
     public void test_print_basicIsoDate_offset() {
         TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), "Z", null);
-        assertEquals(DateTimeFormatters.basicIsoDate().print(test), "20080603Z");
+        assertEquals(DateTimeFormatter.BASIC_ISO_DATE.format(test), "20080603Z");
     }
 
     @Test(groups={"tck"})
     public void test_print_basicIsoDate_zoned() {
         TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), "+02:00", "Europe/Paris");
-        assertEquals(DateTimeFormatters.basicIsoDate().print(test), "20080603+0200");
+        assertEquals(DateTimeFormatter.BASIC_ISO_DATE.format(test), "20080603+0200");
     }
 
-    @Test(expectedExceptions=DateTimePrintException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
     public void test_print_basicIsoDate_largeYear() {
         TemporalAccessor test = buildAccessor(LocalDateTime.of(123456, 6, 3, 11, 5, 30), "Z", null);
-        DateTimeFormatters.basicIsoDate().print(test);
+        DateTimeFormatter.BASIC_ISO_DATE.format(test);
     }
 
     @Test(groups={"tck"})
     public void test_print_basicIsoDate_fields() {
         TemporalAccessor test = buildAccessor(LocalDate.of(2008, 6, 3), null, null);
-        assertEquals(DateTimeFormatters.basicIsoDate().print(test), "20080603");
+        assertEquals(DateTimeFormatter.BASIC_ISO_DATE.format(test), "20080603");
     }
 
     @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
     public void test_print_basicIsoDate_missingField() {
         TemporalAccessor test = YearMonth.of(2008, 6);
-        DateTimeFormatters.basicIsoDate().print(test);
+        DateTimeFormatter.BASIC_ISO_DATE.format(test);
     }
 
     //-----------------------------------------------------------------------
     @Test(groups={"tck"})
     public void test_parse_basicIsoDate() {
         LocalDate expected = LocalDate.of(2008, 6, 3);
-        assertEquals(DateTimeFormatters.basicIsoDate().parse("20080603", LocalDate::from), expected);
+        assertEquals(DateTimeFormatter.BASIC_ISO_DATE.parse("20080603", LocalDate::from), expected);
     }
 
     @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"})
     public void test_parse_basicIsoDate_largeYear() {
         try {
             LocalDate expected = LocalDate.of(123456, 6, 3);
-            assertEquals(DateTimeFormatters.basicIsoDate().parse("+1234560603", LocalDate::from), expected);
+            assertEquals(DateTimeFormatter.BASIC_ISO_DATE.parse("+1234560603", LocalDate::from), expected);
         } catch (DateTimeParseException ex) {
             assertEquals(ex.getErrorIndex(), 0);
             assertEquals(ex.getParsedString(), "+1234560603");
             throw ex;
         }

@@ -1000,44 +1012,44 @@
         };
     }
 
     @Test(dataProvider="weekDate", groups={"tck"})
     public void test_print_isoWeekDate(TemporalAccessor test, String expected) {
-        assertEquals(DateTimeFormatters.isoWeekDate().print(test), expected);
+        assertEquals(DateTimeFormatter.ISO_WEEK_DATE.format(test), expected);
     }
 
     @Test(groups={"tck"})
     public void test_print_isoWeekDate_zoned_largeYear() {
         TemporalAccessor test = buildAccessor(LocalDateTime.of(123456, 6, 3, 11, 5, 30), "Z", null);
-        assertEquals(DateTimeFormatters.isoWeekDate().print(test), "+123456-W23-2Z");
+        assertEquals(DateTimeFormatter.ISO_WEEK_DATE.format(test), "+123456-W23-2Z");
     }
 
     @Test(groups={"tck"})
     public void test_print_isoWeekDate_fields() {
         TemporalAccessor test = buildAccessor(LocalDate.of(2004, 1, 27), null, null);
-        assertEquals(DateTimeFormatters.isoWeekDate().print(test), "2004-W05-2");
+        assertEquals(DateTimeFormatter.ISO_WEEK_DATE.format(test), "2004-W05-2");
     }
 
     @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
     public void test_print_isoWeekDate_missingField() {
         TemporalAccessor test = YearMonth.of(2008, 6);
-        DateTimeFormatters.isoWeekDate().print(test);
+        DateTimeFormatter.ISO_WEEK_DATE.format(test);
     }
 
     //-----------------------------------------------------------------------
     @Test(groups={"tck"})
     public void test_parse_weekDate() {
         LocalDate expected = LocalDate.of(2004, 1, 28);
-        assertEquals(DateTimeFormatters.isoWeekDate().parse("2004-W05-3", LocalDate::from), expected);
+        assertEquals(DateTimeFormatter.ISO_WEEK_DATE.parse("2004-W05-3", LocalDate::from), expected);
     }
 
     @Test(groups={"tck"})
     public void test_parse_weekDate_largeYear() {
-        DateTimeBuilder builder = DateTimeFormatters.isoWeekDate().parseToBuilder("+123456-W04-5", new ParsePosition(0));
-        assertEquals(builder.getFieldValue(ISOFields.WEEK_BASED_YEAR), 123456);
-        assertEquals(builder.getFieldValue(ISOFields.WEEK_OF_WEEK_BASED_YEAR), 4);
-        assertEquals(builder.getFieldValue(DAY_OF_WEEK), 5);
+        TemporalAccessor parsed = DateTimeFormatter.ISO_WEEK_DATE.parseUnresolved("+123456-W04-5", new ParsePosition(0));
+        assertEquals(parsed.getLong(IsoFields.WEEK_BASED_YEAR), 123456L);
+        assertEquals(parsed.getLong(IsoFields.WEEK_OF_WEEK_BASED_YEAR), 4L);
+        assertEquals(parsed.getLong(DAY_OF_WEEK), 5L);
     }
 
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------

@@ -1052,83 +1064,83 @@
     }
 
     @Test(groups={"tck"}, dataProvider="rfc")
     public void test_print_rfc1123(LocalDateTime base, String offsetId, String expected) {
         TemporalAccessor test = buildAccessor(base, offsetId, null);
-        assertEquals(DateTimeFormatters.rfc1123().print(test), expected);
+        assertEquals(DateTimeFormatter.RFC_1123_DATE_TIME.format(test), expected);
     }
 
     @Test(groups={"tck"}, dataProvider="rfc")
     public void test_print_rfc1123_french(LocalDateTime base, String offsetId, String expected) {
         TemporalAccessor test = buildAccessor(base, offsetId, null);
-        assertEquals(DateTimeFormatters.rfc1123().withLocale(Locale.FRENCH).print(test), expected);
+        assertEquals(DateTimeFormatter.RFC_1123_DATE_TIME.withLocale(Locale.FRENCH).format(test), expected);
     }
 
     @Test(groups={"tck"}, expectedExceptions=DateTimeException.class)
     public void test_print_rfc1123_missingField() {
         TemporalAccessor test = YearMonth.of(2008, 6);
-        DateTimeFormatters.rfc1123().print(test);
+        DateTimeFormatter.RFC_1123_DATE_TIME.format(test);
     }
 
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
-    private DateTimeBuilder createDate(Integer year, Integer month, Integer day) {
-        DateTimeBuilder test = new DateTimeBuilder();
+    private Expected createDate(Integer year, Integer month, Integer day) {
+        Expected test = new Expected();
         if (year != null) {
-            test.addFieldValue(YEAR, year);
+            test.fieldValues.put(YEAR, (long) year);
         }
         if (month != null) {
-            test.addFieldValue(MONTH_OF_YEAR, month);
+            test.fieldValues.put(MONTH_OF_YEAR, (long) month);
         }
         if (day != null) {
-            test.addFieldValue(DAY_OF_MONTH, day);
+            test.fieldValues.put(DAY_OF_MONTH, (long) day);
         }
         return test;
     }
 
-    private DateTimeBuilder createTime(Integer hour, Integer min, Integer sec, Integer nano) {
-        DateTimeBuilder test = new DateTimeBuilder();
+    private Expected createTime(Integer hour, Integer min, Integer sec, Integer nano) {
+        Expected test = new Expected();
         if (hour != null) {
-            test.addFieldValue(HOUR_OF_DAY, hour);
+            test.fieldValues.put(HOUR_OF_DAY, (long) hour);
         }
         if (min != null) {
-            test.addFieldValue(MINUTE_OF_HOUR, min);
+            test.fieldValues.put(MINUTE_OF_HOUR, (long) min);
         }
         if (sec != null) {
-            test.addFieldValue(SECOND_OF_MINUTE, sec);
+            test.fieldValues.put(SECOND_OF_MINUTE, (long) sec);
         }
         if (nano != null) {
-            test.addFieldValue(NANO_OF_SECOND, nano);
+            test.fieldValues.put(NANO_OF_SECOND, (long) nano);
         }
         return test;
     }
 
-    private DateTimeBuilder createDateTime(
+    private Expected createDateTime(
             Integer year, Integer month, Integer day,
             Integer hour, Integer min, Integer sec, Integer nano) {
-        DateTimeBuilder test = new DateTimeBuilder();
+        Expected test = new Expected();
         if (year != null) {
-            test.addFieldValue(YEAR, year);
+            test.fieldValues.put(YEAR, (long) year);
         }
         if (month != null) {
-            test.addFieldValue(MONTH_OF_YEAR, month);
+            test.fieldValues.put(MONTH_OF_YEAR, (long) month);
         }
         if (day != null) {
-            test.addFieldValue(DAY_OF_MONTH, day);
+            test.fieldValues.put(DAY_OF_MONTH, (long) day);
         }
         if (hour != null) {
-            test.addFieldValue(HOUR_OF_DAY, hour);
+            test.fieldValues.put(HOUR_OF_DAY, (long) hour);
         }
         if (min != null) {
-            test.addFieldValue(MINUTE_OF_HOUR, min);
+            test.fieldValues.put(MINUTE_OF_HOUR, (long) min);
         }
         if (sec != null) {
-            test.addFieldValue(SECOND_OF_MINUTE, sec);
+            test.fieldValues.put(SECOND_OF_MINUTE, (long) sec);
         }
         if (nano != null) {
-            test.addFieldValue(NANO_OF_SECOND, nano);
+            test.fieldValues.put(NANO_OF_SECOND, (long) nano);
         }
         return test;
     }
 
     private TemporalAccessor buildAccessor(

@@ -1176,27 +1188,26 @@
         mock.setOffset(offsetId);
         mock.setZone(zoneId);
         return mock;
     }
 
-    private void buildCalendrical(DateTimeBuilder cal, String offsetId, String zoneId) {
+    private void buildCalendrical(Expected expected, String offsetId, String zoneId) {
         if (offsetId != null) {
-            cal.addFieldValue(OFFSET_SECONDS, ZoneOffset.of(offsetId).getTotalSeconds());
+            expected.add(ZoneOffset.of(offsetId));
         }
         if (zoneId != null) {
-            cal.addCalendrical(ZoneId.of(zoneId));
+            expected.zone = ZoneId.of(zoneId);
         }
     }
 
-    private void assertParseMatch(DateTimeBuilder parsed, DateTimeBuilder expected) {
-        Map<TemporalField, Long> parsedFVMap = parsed.getFieldValueMap();
-        Map<TemporalField, Long> expectedFVMap = expected.getFieldValueMap();
-        assertEquals(parsedFVMap, expectedFVMap);
-
-        List<Object> parsedCMap = parsed.getCalendricalList();
-        List<Object> expectedCMap = expected.getCalendricalList();
-        assertEquals(parsedCMap, expectedCMap);
+    private void assertParseMatch(TemporalAccessor parsed, Expected expected) {
+        for (TemporalField field : expected.fieldValues.keySet()) {
+            assertEquals(parsed.isSupported(field), true);
+            parsed.getLong(field);
+        }
+        assertEquals(parsed.query(Queries.chronology()), expected.chrono);
+        assertEquals(parsed.query(Queries.zoneId()), expected.zone);
     }
 
     //-------------------------------------------------------------------------
         Map<TemporalField, Long> fields = new HashMap<>();
         ZoneId zoneId;

@@ -1209,24 +1220,24 @@
                 fields.put(YEAR, (long) dt.getYear());
                 fields.put(MONTH_OF_YEAR, (long) dt.getMonthValue());
                 fields.put(DAY_OF_MONTH, (long) dt.getDayOfMonth());
                 fields.put(DAY_OF_YEAR, (long) dt.getDayOfYear());
                 fields.put(DAY_OF_WEEK, (long) dt.getDayOfWeek().getValue());
-                fields.put(ISOFields.WEEK_BASED_YEAR, dt.getLong(ISOFields.WEEK_BASED_YEAR));
-                fields.put(ISOFields.WEEK_OF_WEEK_BASED_YEAR, dt.getLong(ISOFields.WEEK_OF_WEEK_BASED_YEAR));
+                fields.put(IsoFields.WEEK_BASED_YEAR, dt.getLong(IsoFields.WEEK_BASED_YEAR));
+                fields.put(IsoFields.WEEK_OF_WEEK_BASED_YEAR, dt.getLong(IsoFields.WEEK_OF_WEEK_BASED_YEAR));
             }
         }
 
         void setFields(LocalDateTime dt) {
             if (dt != null) {
                 fields.put(YEAR, (long) dt.getYear());
                 fields.put(MONTH_OF_YEAR, (long) dt.getMonthValue());
                 fields.put(DAY_OF_MONTH, (long) dt.getDayOfMonth());
                 fields.put(DAY_OF_YEAR, (long) dt.getDayOfYear());
                 fields.put(DAY_OF_WEEK, (long) dt.getDayOfWeek().getValue());
-                fields.put(ISOFields.WEEK_BASED_YEAR, dt.getLong(ISOFields.WEEK_BASED_YEAR));
-                fields.put(ISOFields.WEEK_OF_WEEK_BASED_YEAR, dt.getLong(ISOFields.WEEK_OF_WEEK_BASED_YEAR));
+                fields.put(IsoFields.WEEK_BASED_YEAR, dt.getLong(IsoFields.WEEK_BASED_YEAR));
+                fields.put(IsoFields.WEEK_OF_WEEK_BASED_YEAR, dt.getLong(IsoFields.WEEK_OF_WEEK_BASED_YEAR));
                 fields.put(HOUR_OF_DAY, (long) dt.getHour());
                 fields.put(MINUTE_OF_HOUR, (long) dt.getMinute());
                 fields.put(SECOND_OF_MINUTE, (long) dt.getSecond());
                 fields.put(NANO_OF_SECOND, (long) dt.getNano());
             }

@@ -1271,6 +1282,24 @@
         public String toString() {
             return fields + (zoneId != null ? " " + zoneId : "");
         }
     }
 
+    //-----------------------------------------------------------------------
+    static class Expected {
+        Map<TemporalField, Long> fieldValues = new HashMap<>();
+        ZoneId zone;
+        Chronology chrono;
+
+        Expected() {
+        }
+
+        Expected(TemporalField field1, long value1, TemporalField field2, long value2) {
+            fieldValues.put(field1, value1);
+            fieldValues.put(field2, value2);
+        }
+
+        void add(ZoneOffset offset) {
+            fieldValues.put(OFFSET_SECONDS, (long) offset.getTotalSeconds());
+        }
+    }
 }