From 3ee0b4a488329e590d9cefd1227d149bd1eb8093 Mon Sep 17 00:00:00 2001 From: Przemyslaw Gomulka Date: Tue, 22 Oct 2019 14:58:21 +0200 Subject: [PATCH 1/6] [Java.time] Calculate week of a year with ISO rules (#48209) Reverting the change introducing IsoLocal.ROOT and introducing IsoCalendarDataProvider that defaults start of the week to Monday and requires minimum 4 days in first week of a year. This extension is using java SPI mechanism and defaults for Locale.ROOT only. It require jvm property java.locale.providers to be set with SPI,COMPAT closes #41670 --- .../elasticsearch/gradle/BuildPlugin.groovy | 3 + .../gradle/test/RestIntegTestTask.groovy | 1 + distribution/src/config/jvm.options | 2 +- .../common/time/DateFormatters.java | 67 ++++++++++--------- .../common/time/IsoCalendarDataProvider.java | 41 ++++++++++++ .../script/JodaCompatibleZonedDateTime.java | 10 +-- .../java.util.spi.CalendarDataProvider | 1 + .../joda/JavaJodaTimeDuellingTests.java | 2 +- .../common/time/DateFormattersTests.java | 26 +++++++ .../common/time/JavaDateMathParserTests.java | 14 ++++ .../index/mapper/DateFieldMapperTests.java | 2 +- .../JodaCompatibleZonedDateTimeTests.java | 4 +- .../search/query/SearchQueryIT.java | 12 ++-- .../license/LicenseServiceTests.java | 17 +---- .../datetime/NonIsoDateTimeProcessor.java | 16 +---- .../NonIsoDateTimeProcessorTests.java | 5 +- 16 files changed, 146 insertions(+), 77 deletions(-) create mode 100644 server/src/main/java/org/elasticsearch/common/time/IsoCalendarDataProvider.java create mode 100644 server/src/main/resources/META-INF/services/java.util.spi.CalendarDataProvider diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 27e792d6638f8..e681cc816bc5d 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -876,6 +876,9 @@ class BuildPlugin implements Plugin { 'tests.security.manager': 'true', 'jna.nosys': 'true' + //TODO remove once jvm.options are added to test system properties + test.systemProperty ('java.locale.providers','SPI,COMPAT') + // ignore changing test seed when build is passed -Dignore.tests.seed for cacheability experimentation if (System.getProperty('ignore.tests.seed') != null) { nonInputProperties.systemProperty('tests.seed', project.property('testSeed')) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy index 879a22292d3e2..2bd1da35d4ddd 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy @@ -24,6 +24,7 @@ import org.elasticsearch.gradle.testclusters.RestTestRunnerTask import org.elasticsearch.gradle.tool.Boilerplate import org.elasticsearch.gradle.tool.ClasspathUtils import org.gradle.api.DefaultTask +import org.gradle.api.JavaVersion import org.gradle.api.Task import org.gradle.api.file.FileCopyDetails import org.gradle.api.tasks.Copy diff --git a/distribution/src/config/jvm.options b/distribution/src/config/jvm.options index 2fbc58ff860db..ba5d4dae67a17 100644 --- a/distribution/src/config/jvm.options +++ b/distribution/src/config/jvm.options @@ -117,4 +117,4 @@ ${error.file} 9-:-Xlog:gc*,gc+age=trace,safepoint:file=${loggc}:utctime,pid,tags:filecount=32,filesize=64m # due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise # time/date parsing will break in an incompatible way for some date patterns and locals -9-:-Djava.locale.providers=COMPAT +-Djava.locale.providers=SPI,COMPAT diff --git a/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java b/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java index 288da5cff271f..073361505a70e 100644 --- a/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java +++ b/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java @@ -22,7 +22,6 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.SuppressForbidden; -import java.time.DayOfWeek; import java.time.Instant; import java.time.LocalDate; import java.time.LocalTime; @@ -37,7 +36,6 @@ import java.time.temporal.ChronoField; import java.time.temporal.IsoFields; import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalAdjusters; import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.time.temporal.WeekFields; @@ -53,6 +51,7 @@ import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; public class DateFormatters { + public static final WeekFields WEEK_FIELDS = WeekFields.of(Locale.ROOT); private static final DateTimeFormatter TIME_ZONE_FORMATTER_NO_COLON = new DateTimeFormatterBuilder() .appendOffset("+HHmm", "Z") @@ -946,14 +945,14 @@ public class DateFormatters { * Returns a formatter for a four digit weekyear */ private static final DateFormatter STRICT_WEEKYEAR = new JavaDateFormatter("strict_weekyear", new DateTimeFormatterBuilder() - .appendValue(WeekFields.ISO.weekBasedYear(), 4, 10, SignStyle.EXCEEDS_PAD) + .appendValue(WEEK_FIELDS.weekBasedYear(), 4, 10, SignStyle.EXCEEDS_PAD) .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT)); private static final DateTimeFormatter STRICT_WEEKYEAR_WEEK_FORMATTER = new DateTimeFormatterBuilder() - .appendValue(WeekFields.ISO.weekBasedYear(), 4, 10, SignStyle.EXCEEDS_PAD) + .appendValue(WEEK_FIELDS.weekBasedYear(), 4, 10, SignStyle.EXCEEDS_PAD) .appendLiteral("-W") - .appendValue(WeekFields.ISO.weekOfWeekBasedYear(), 2, 2, SignStyle.NOT_NEGATIVE) + .appendValue(WEEK_FIELDS.weekOfWeekBasedYear(), 2, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); @@ -972,7 +971,7 @@ public class DateFormatters { new DateTimeFormatterBuilder() .append(STRICT_WEEKYEAR_WEEK_FORMATTER) .appendLiteral("-") - .appendValue(WeekFields.ISO.dayOfWeek()) + .appendValue(WEEK_FIELDS.dayOfWeek()) .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT)); @@ -1162,7 +1161,7 @@ public class DateFormatters { * Returns a formatter for a four digit weekyear. (YYYY) */ private static final DateFormatter WEEK_YEAR = new JavaDateFormatter("week_year", - new DateTimeFormatterBuilder().appendValue(WeekFields.ISO.weekBasedYear()).toFormatter(Locale.ROOT) + new DateTimeFormatterBuilder().appendValue(WEEK_FIELDS.weekBasedYear()).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT)); /* @@ -1591,9 +1590,9 @@ public class DateFormatters { */ private static final DateFormatter WEEKYEAR_WEEK = new JavaDateFormatter("weekyear_week", STRICT_WEEKYEAR_WEEK_FORMATTER, new DateTimeFormatterBuilder() - .appendValue(WeekFields.ISO.weekBasedYear()) + .appendValue(WEEK_FIELDS.weekBasedYear()) .appendLiteral("-W") - .appendValue(WeekFields.ISO.weekOfWeekBasedYear()) + .appendValue(WEEK_FIELDS.weekOfWeekBasedYear()) .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1606,15 +1605,15 @@ public class DateFormatters { new DateTimeFormatterBuilder() .append(STRICT_WEEKYEAR_WEEK_FORMATTER) .appendLiteral("-") - .appendValue(WeekFields.ISO.dayOfWeek()) + .appendValue(WEEK_FIELDS.dayOfWeek()) .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() - .appendValue(WeekFields.ISO.weekBasedYear()) + .appendValue(WEEK_FIELDS.weekBasedYear()) .appendLiteral("-W") - .appendValue(WeekFields.ISO.weekOfWeekBasedYear()) + .appendValue(WEEK_FIELDS.weekOfWeekBasedYear()) .appendLiteral("-") - .appendValue(WeekFields.ISO.dayOfWeek()) + .appendValue(WEEK_FIELDS.dayOfWeek()) .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1858,7 +1857,7 @@ public static ZonedDateTime from(TemporalAccessor accessor) { } else if (isLocalDateSet) { return localDate.atStartOfDay(zoneId); } else if (isLocalTimeSet) { - return of(getLocaldate(accessor), localTime, zoneId); + return of(getLocalDate(accessor), localTime, zoneId); } else if (accessor.isSupported(ChronoField.YEAR) || accessor.isSupported(ChronoField.YEAR_OF_ERA) ) { if (accessor.isSupported(MONTH_OF_YEAR)) { return getFirstOfMonth(accessor).atStartOfDay(zoneId); @@ -1868,19 +1867,9 @@ public static ZonedDateTime from(TemporalAccessor accessor) { } } else if (accessor.isSupported(MONTH_OF_YEAR)) { // missing year, falling back to the epoch and then filling - return getLocaldate(accessor).atStartOfDay(zoneId); - } else if (accessor.isSupported(WeekFields.ISO.weekBasedYear())) { - if (accessor.isSupported(WeekFields.ISO.weekOfWeekBasedYear())) { - return Year.of(accessor.get(WeekFields.ISO.weekBasedYear())) - .atDay(1) - .with(WeekFields.ISO.weekOfWeekBasedYear(), accessor.getLong(WeekFields.ISO.weekOfWeekBasedYear())) - .atStartOfDay(zoneId); - } else { - return Year.of(accessor.get(WeekFields.ISO.weekBasedYear())) - .atDay(1) - .with(TemporalAdjusters.firstInMonth(DayOfWeek.MONDAY)) - .atStartOfDay(zoneId); - } + return getLocalDate(accessor).atStartOfDay(zoneId); + } else if (accessor.isSupported(WEEK_FIELDS.weekBasedYear())) { + return localDateFromWeekBasedDate(accessor).atStartOfDay(zoneId); } // we should not reach this piece of code, everything being parsed we should be able to @@ -1888,6 +1877,19 @@ public static ZonedDateTime from(TemporalAccessor accessor) { throw new IllegalArgumentException("temporal accessor [" + accessor + "] cannot be converted to zoned date time"); } + private static LocalDate localDateFromWeekBasedDate(TemporalAccessor accessor) { + if (accessor.isSupported(WEEK_FIELDS.weekOfWeekBasedYear())) { + return LocalDate.ofEpochDay(0) + .with(WEEK_FIELDS.weekBasedYear(), accessor.get(WEEK_FIELDS.weekBasedYear())) + .with(WEEK_FIELDS.weekOfWeekBasedYear(), accessor.get(WEEK_FIELDS.weekOfWeekBasedYear())) + .with(ChronoField.DAY_OF_WEEK, WEEK_FIELDS.getFirstDayOfWeek().getValue()); + } else { + return LocalDate.ofEpochDay(0) + .with(WEEK_FIELDS.weekBasedYear(), accessor.get(WEEK_FIELDS.weekBasedYear())) + .with(ChronoField.DAY_OF_WEEK, WEEK_FIELDS.getFirstDayOfWeek().getValue()); + } + } + /** * extending the java.time.temporal.TemporalQueries.LOCAL_DATE implementation to also create local dates * when YearOfEra was used instead of Year. @@ -1915,15 +1917,17 @@ public String toString() { } }; - private static LocalDate getLocaldate(TemporalAccessor accessor) { - int year = getYear(accessor); - if (accessor.isSupported(MONTH_OF_YEAR)) { + private static LocalDate getLocalDate(TemporalAccessor accessor) { + if (accessor.isSupported(WEEK_FIELDS.weekBasedYear())) { + return localDateFromWeekBasedDate(accessor); + } else if (accessor.isSupported(MONTH_OF_YEAR)) { + int year = getYear(accessor); if (accessor.isSupported(DAY_OF_MONTH)) { return LocalDate.of(year, accessor.get(MONTH_OF_YEAR), accessor.get(DAY_OF_MONTH)); } else { return LocalDate.of(year, accessor.get(MONTH_OF_YEAR), 1); } - } + } else return LOCALDATE_EPOCH; } @@ -1935,6 +1939,7 @@ private static int getYear(TemporalAccessor accessor) { if(accessor.isSupported(ChronoField.YEAR_OF_ERA)){ return accessor.get(ChronoField.YEAR_OF_ERA); } + return 1970; } diff --git a/server/src/main/java/org/elasticsearch/common/time/IsoCalendarDataProvider.java b/server/src/main/java/org/elasticsearch/common/time/IsoCalendarDataProvider.java new file mode 100644 index 0000000000000..36a93049adeb8 --- /dev/null +++ b/server/src/main/java/org/elasticsearch/common/time/IsoCalendarDataProvider.java @@ -0,0 +1,41 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.elasticsearch.common.time; + +import java.util.Calendar; +import java.util.Locale; +import java.util.spi.CalendarDataProvider; + +public class IsoCalendarDataProvider extends CalendarDataProvider { + + @Override + public int getFirstDayOfWeek(Locale locale) { + return Calendar.MONDAY; + } + + @Override + public int getMinimalDaysInFirstWeek(Locale locale) { + return 4; + } + + @Override + public Locale[] getAvailableLocales() { + return new Locale[]{Locale.ROOT}; + } +} diff --git a/server/src/main/java/org/elasticsearch/script/JodaCompatibleZonedDateTime.java b/server/src/main/java/org/elasticsearch/script/JodaCompatibleZonedDateTime.java index 2c09456ed4302..1370f988ac7d1 100644 --- a/server/src/main/java/org/elasticsearch/script/JodaCompatibleZonedDateTime.java +++ b/server/src/main/java/org/elasticsearch/script/JodaCompatibleZonedDateTime.java @@ -23,6 +23,7 @@ import org.elasticsearch.common.SuppressForbidden; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.time.DateFormatter; +import org.elasticsearch.common.time.DateFormatters; import org.elasticsearch.common.time.DateUtils; import org.joda.time.DateTime; @@ -50,7 +51,6 @@ import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; import java.time.temporal.ValueRange; -import java.time.temporal.WeekFields; import java.util.Locale; import java.util.Objects; @@ -474,14 +474,14 @@ public int getSecondOfMinute() { @Deprecated public int getWeekOfWeekyear() { - logDeprecatedMethod("getWeekOfWeekyear()", "get(WeekFields.ISO.weekOfWeekBasedYear())"); - return dt.get(WeekFields.ISO.weekOfWeekBasedYear()); + logDeprecatedMethod("getWeekOfWeekyear()", "get(DateFormatters.WEEK_FIELDS.weekOfWeekBasedYear())"); + return dt.get(DateFormatters.WEEK_FIELDS.weekOfWeekBasedYear()); } @Deprecated public int getWeekyear() { - logDeprecatedMethod("getWeekyear()", "get(WeekFields.ISO.weekBasedYear())"); - return dt.get(WeekFields.ISO.weekBasedYear()); + logDeprecatedMethod("getWeekyear()", "get(DateFormatters.WEEK_FIELDS.weekBasedYear())"); + return dt.get(DateFormatters.WEEK_FIELDS.weekBasedYear()); } @Deprecated diff --git a/server/src/main/resources/META-INF/services/java.util.spi.CalendarDataProvider b/server/src/main/resources/META-INF/services/java.util.spi.CalendarDataProvider new file mode 100644 index 0000000000000..6e006ccf815f8 --- /dev/null +++ b/server/src/main/resources/META-INF/services/java.util.spi.CalendarDataProvider @@ -0,0 +1 @@ +org.elasticsearch.common.time.IsoCalendarDataProvider \ No newline at end of file diff --git a/server/src/test/java/org/elasticsearch/common/joda/JavaJodaTimeDuellingTests.java b/server/src/test/java/org/elasticsearch/common/joda/JavaJodaTimeDuellingTests.java index 81f98d3ad752b..49e069ceb6f5a 100644 --- a/server/src/test/java/org/elasticsearch/common/joda/JavaJodaTimeDuellingTests.java +++ b/server/src/test/java/org/elasticsearch/common/joda/JavaJodaTimeDuellingTests.java @@ -37,9 +37,9 @@ import java.time.temporal.TemporalAccessor; import java.util.Locale; +import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; -import static org.hamcrest.core.IsEqual.equalTo; public class JavaJodaTimeDuellingTests extends ESTestCase { @Override diff --git a/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java b/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java index c5956e5c29a23..a3b8a732d195d 100644 --- a/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java +++ b/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java @@ -40,6 +40,32 @@ public class DateFormattersTests extends ESTestCase { + public void testWeekBasedDates() { + // as per WeekFields.ISO first week starts on Monday and has minimum 4 days + DateFormatter dateFormatter = DateFormatters.forPattern("YYYY-ww"); + + // first week of 2016 starts on Monday 2016-01-04 as previous week in 2016 has only 3 days + assertThat(DateFormatters.from(dateFormatter.parse("2016-01")) , + equalTo(ZonedDateTime.of(2016,01,04, 0,0,0,0,ZoneOffset.UTC))); + + // first week of 2015 starts on Monday 2014-12-29 because 4days belong to 2019 + assertThat(DateFormatters.from(dateFormatter.parse("2015-01")) , + equalTo(ZonedDateTime.of(2014,12,29, 0,0,0,0,ZoneOffset.UTC))); + + + // as per WeekFields.ISO first week starts on Monday and has minimum 4 days + dateFormatter = DateFormatters.forPattern("YYYY"); + + // first week of 2016 starts on Monday 2016-01-04 as previous week in 2016 has only 3 days + assertThat(DateFormatters.from(dateFormatter.parse("2016")) , + equalTo(ZonedDateTime.of(2016,01,04, 0,0,0,0,ZoneOffset.UTC))); + + // first week of 2015 starts on Monday 2014-12-29 because 4days belong to 2019 + assertThat(DateFormatters.from(dateFormatter.parse("2015")) , + equalTo(ZonedDateTime.of(2014,12,29, 0,0,0,0,ZoneOffset.UTC))); + } + + // this is not in the duelling tests, because the epoch millis parser in joda time drops the milliseconds after the comma // but is able to parse the rest // as this feature is supported it also makes sense to make it exact diff --git a/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java b/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java index 34903e024d05d..8a4aacb6bbd19 100644 --- a/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java +++ b/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java @@ -50,6 +50,20 @@ public void testOverridingLocaleOrZoneAndCompositeRoundUpParser() { assertDateEquals(gotMillis, "297276785531", "297276785531"); } + public void testWeekDates() { + DateFormatter formatter = DateFormatter.forPattern("YYYY-ww"); + assertDateMathEquals(formatter.toDateMathParser(), "2016-01", "2016-01-04T23:59:59.999Z", 0, true, ZoneOffset.UTC); + + formatter = DateFormatter.forPattern("YYYY"); + assertDateMathEquals(formatter.toDateMathParser(), "2016", "2016-01-04T23:59:59.999Z", 0, true, ZoneOffset.UTC); + + formatter = DateFormatter.forPattern("YYYY-ww"); + assertDateMathEquals(formatter.toDateMathParser(), "2015-01", "2014-12-29T23:59:59.999Z", 0, true, ZoneOffset.UTC); + + formatter = DateFormatter.forPattern("YYYY"); + assertDateMathEquals(formatter.toDateMathParser(), "2015", "2014-12-29T23:59:59.999Z", 0, true, ZoneOffset.UTC); + } + public void testBasicDates() { assertDateMathEquals("2014-05-30", "2014-05-30T00:00:00.000"); assertDateMathEquals("2014-05-30T20", "2014-05-30T20:00:00.000"); diff --git a/server/src/test/java/org/elasticsearch/index/mapper/DateFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/DateFieldMapperTests.java index 38b3d5a2f1ff2..76484ab39d22c 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/DateFieldMapperTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/DateFieldMapperTests.java @@ -235,7 +235,7 @@ public void testChangeLocale() throws IOException { mapper.parse(new SourceToParse("test", "type", "1", BytesReference .bytes(XContentFactory.jsonBuilder() .startObject() - .field("field", "Mi., 06 Dez. 2000 02:55:00 -0800") + .field("field", "Mi, 06 Dez 2000 02:55:00 -0800") .endObject()), XContentType.JSON)); } diff --git a/server/src/test/java/org/elasticsearch/script/JodaCompatibleZonedDateTimeTests.java b/server/src/test/java/org/elasticsearch/script/JodaCompatibleZonedDateTimeTests.java index 4750ee36b0bd6..9ed651bf70a41 100644 --- a/server/src/test/java/org/elasticsearch/script/JodaCompatibleZonedDateTimeTests.java +++ b/server/src/test/java/org/elasticsearch/script/JodaCompatibleZonedDateTimeTests.java @@ -213,12 +213,12 @@ public void testSecondOfMinute() { public void testWeekOfWeekyear() { assertMethodDeprecation(() -> assertThat(javaTime.getWeekOfWeekyear(), equalTo(jodaTime.getWeekOfWeekyear())), - "getWeekOfWeekyear()", "get(WeekFields.ISO.weekOfWeekBasedYear())"); + "getWeekOfWeekyear()", "get(DateFormatters.WEEK_FIELDS.weekOfWeekBasedYear())"); } public void testWeekyear() { assertMethodDeprecation(() -> assertThat(javaTime.getWeekyear(), equalTo(jodaTime.getWeekyear())), - "getWeekyear()", "get(WeekFields.ISO.weekBasedYear())"); + "getWeekyear()", "get(DateFormatters.WEEK_FIELDS.weekBasedYear())"); } public void testYearOfCentury() { diff --git a/server/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java b/server/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java index 37688645f1d7d..3ef3e28ade0d2 100644 --- a/server/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java +++ b/server/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java @@ -1678,21 +1678,21 @@ public void testRangeQueryWithLocaleMapping() throws Exception { .endObject().endObject().endObject())); indexRandom(true, - client().prepareIndex("test", "type1", "1").setSource("date_field", "Mi., 06 Dez. 2000 02:55:00 -0800"), - client().prepareIndex("test", "type1", "2").setSource("date_field", "Do., 07 Dez. 2000 02:55:00 -0800") + client().prepareIndex("test", "type1", "1").setSource("date_field", "Mi, 06 Dez 2000 02:55:00 -0800"), + client().prepareIndex("test", "type1", "2").setSource("date_field", "Do, 07 Dez 2000 02:55:00 -0800") ); SearchResponse searchResponse = client().prepareSearch("test") .setQuery(QueryBuilders.rangeQuery("date_field") - .gte("Di., 05 Dez. 2000 02:55:00 -0800") - .lte("Do., 07 Dez. 2000 00:00:00 -0800")) + .gte("Di, 05 Dez 2000 02:55:00 -0800") + .lte("Do, 07 Dez 2000 00:00:00 -0800")) .get(); assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch("test") .setQuery(QueryBuilders.rangeQuery("date_field") - .gte("Di., 05 Dez. 2000 02:55:00 -0800") - .lte("Fr., 08 Dez. 2000 00:00:00 -0800")) + .gte("Di, 05 Dez 2000 02:55:00 -0800") + .lte("Fr, 08 Dez 2000 00:00:00 -0800")) .get(); assertHitCount(searchResponse, 2L); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/LicenseServiceTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/LicenseServiceTests.java index 1f65efc630915..57394e647c9ea 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/LicenseServiceTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/LicenseServiceTests.java @@ -17,23 +17,11 @@ /** * Due to changes in JDK9 where locale data is used from CLDR, the licence message will differ in jdk 8 and jdk9+ * https://openjdk.java.net/jeps/252 + * We run ES with -Djava.locale.providers=SPI,COMPAT and same option has to be applied when running this test from IDE */ public class LicenseServiceTests extends ESTestCase { - public void testLogExpirationWarningOnJdk9AndNewer() { - assumeTrue("this is for JDK9+", JavaVersion.current().compareTo(JavaVersion.parse("9")) >= 0); - - long time = LocalDate.of(2018, 11, 15).atStartOfDay(ZoneOffset.UTC).toInstant().toEpochMilli(); - final boolean expired = randomBoolean(); - final String message = LicenseService.buildExpirationMessage(time, expired).toString(); - if (expired) { - assertThat(message, startsWith("LICENSE [EXPIRED] ON [THU, NOV 15, 2018].\n")); - } else { - assertThat(message, startsWith("License [will expire] on [Thu, Nov 15, 2018].\n")); - } - } - - public void testLogExpirationWarningOnJdk8() { + public void testLogExpirationWarning() { assumeTrue("this is for JDK8 only", JavaVersion.current().equals(JavaVersion.parse("8"))); long time = LocalDate.of(2018, 11, 15).atStartOfDay(ZoneOffset.UTC).toInstant().toEpochMilli(); @@ -45,5 +33,4 @@ public void testLogExpirationWarningOnJdk8() { assertThat(message, startsWith("License [will expire] on [Thursday, November 15, 2018].\n")); } } - } diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/datetime/NonIsoDateTimeProcessor.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/datetime/NonIsoDateTimeProcessor.java index 7f916be31bdb1..785a815a45c2a 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/datetime/NonIsoDateTimeProcessor.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/datetime/NonIsoDateTimeProcessor.java @@ -10,14 +10,12 @@ import org.elasticsearch.common.io.stream.StreamOutput; import java.io.IOException; -import java.time.LocalDateTime; +import java.time.DayOfWeek; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.temporal.ChronoField; -import java.util.Calendar; -import java.util.Locale; +import java.time.temporal.WeekFields; import java.util.Objects; -import java.util.TimeZone; import java.util.function.Function; public class NonIsoDateTimeProcessor extends BaseDateTimeProcessor { @@ -30,15 +28,7 @@ public enum NonIsoDateTimeExtractor { return dayOfWeek == 8 ? 1 : dayOfWeek; }), WEEK_OF_YEAR(zdt -> { - // by ISO 8601 standard, the first week of a year is the first week with a majority (4 or more) of its days in January. - // Other Locales may have their own standards (see Arabic or Japanese calendars). - LocalDateTime ld = zdt.toLocalDateTime(); - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(zdt.getZone()), Locale.ROOT); - cal.clear(); - cal.set(ld.get(ChronoField.YEAR), ld.get(ChronoField.MONTH_OF_YEAR) - 1, ld.get(ChronoField.DAY_OF_MONTH), - ld.get(ChronoField.HOUR_OF_DAY), ld.get(ChronoField.MINUTE_OF_HOUR), ld.get(ChronoField.SECOND_OF_MINUTE)); - - return cal.get(Calendar.WEEK_OF_YEAR); + return zdt.get(WeekFields.of(DayOfWeek.SUNDAY, 1).weekOfWeekBasedYear()); }); private final Function apply; diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/expression/function/scalar/datetime/NonIsoDateTimeProcessorTests.java b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/expression/function/scalar/datetime/NonIsoDateTimeProcessorTests.java index a2ee6796f668d..a1971cecad1d5 100644 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/expression/function/scalar/datetime/NonIsoDateTimeProcessorTests.java +++ b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/expression/function/scalar/datetime/NonIsoDateTimeProcessorTests.java @@ -16,7 +16,6 @@ import static org.elasticsearch.xpack.sql.util.DateUtils.UTC; public class NonIsoDateTimeProcessorTests extends AbstractSqlWireSerializingTestCase { - public static NonIsoDateTimeProcessor randomNonISODateTimeProcessor() { return new NonIsoDateTimeProcessor(randomFrom(NonIsoDateTimeExtractor.values()), UTC); @@ -45,6 +44,8 @@ protected ZoneId instanceZoneId(NonIsoDateTimeProcessor instance) { public void testNonISOWeekOfYearInUTC() { NonIsoDateTimeProcessor proc = new NonIsoDateTimeProcessor(NonIsoDateTimeExtractor.WEEK_OF_YEAR, UTC); + // 1 Jan 1988 is Friday - under Sunday,1 rule it is the first week of the year (under ISO rule it would be 53 of the previous year + // hence the 5th Jan 1988 Tuesday is the second week of a year assertEquals(2, proc.process(dateTime(568372930000L))); //1988-01-05T09:22:10Z[UTC] assertEquals(6, proc.process(dateTime(981278530000L))); //2001-02-04T09:22:10Z[UTC] assertEquals(7, proc.process(dateTime(224241730000L))); //1977-02-08T09:22:10Z[UTC] @@ -94,4 +95,4 @@ public void testNonISODayOfWeekInNonUTCTimeZone() { assertEquals(6, proc.process(dateTime(333451330000L))); assertEquals(5, proc.process(dateTime(874660930000L))); } -} \ No newline at end of file +} From 1b406e314643f9705d6cbd023e6283fee0b30543 Mon Sep 17 00:00:00 2001 From: Przemyslaw Gomulka Date: Tue, 22 Oct 2019 15:13:08 +0200 Subject: [PATCH 2/6] cleanup --- .../org/elasticsearch/gradle/test/RestIntegTestTask.groovy | 1 - .../java/org/elasticsearch/common/time/DateFormatters.java | 3 +-- .../org/elasticsearch/common/time/DateFormattersTests.java | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy index 2bd1da35d4ddd..879a22292d3e2 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy @@ -24,7 +24,6 @@ import org.elasticsearch.gradle.testclusters.RestTestRunnerTask import org.elasticsearch.gradle.tool.Boilerplate import org.elasticsearch.gradle.tool.ClasspathUtils import org.gradle.api.DefaultTask -import org.gradle.api.JavaVersion import org.gradle.api.Task import org.gradle.api.file.FileCopyDetails import org.gradle.api.tasks.Copy diff --git a/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java b/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java index 073361505a70e..331f96e9e0840 100644 --- a/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java +++ b/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java @@ -1927,7 +1927,7 @@ private static LocalDate getLocalDate(TemporalAccessor accessor) { } else { return LocalDate.of(year, accessor.get(MONTH_OF_YEAR), 1); } - } else + } return LOCALDATE_EPOCH; } @@ -1939,7 +1939,6 @@ private static int getYear(TemporalAccessor accessor) { if(accessor.isSupported(ChronoField.YEAR_OF_ERA)){ return accessor.get(ChronoField.YEAR_OF_ERA); } - return 1970; } diff --git a/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java b/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java index a3b8a732d195d..a048edcfb7091 100644 --- a/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java +++ b/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java @@ -65,7 +65,6 @@ public void testWeekBasedDates() { equalTo(ZonedDateTime.of(2014,12,29, 0,0,0,0,ZoneOffset.UTC))); } - // this is not in the duelling tests, because the epoch millis parser in joda time drops the milliseconds after the comma // but is able to parse the rest // as this feature is supported it also makes sense to make it exact From d733e67a98f503a56fbb7b28bd7576e4525205c8 Mon Sep 17 00:00:00 2001 From: Przemyslaw Gomulka Date: Tue, 22 Oct 2019 19:15:12 +0200 Subject: [PATCH 3/6] teste fixtures and disabled --- .../common/time/DateFormatters.java | 354 +++++++++--------- .../common/time/DateFormattersTests.java | 3 + .../common/time/JavaDateMathParserTests.java | 3 + .../bootstrap/BootstrapForTesting.java | 12 +- .../TimestampFormatFinderTests.java | 3 + 5 files changed, 193 insertions(+), 182 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java b/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java index 331f96e9e0840..b695a8834fdc8 100644 --- a/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java +++ b/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java @@ -22,6 +22,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.SuppressForbidden; +import java.time.DayOfWeek; import java.time.Instant; import java.time.LocalDate; import java.time.LocalTime; @@ -29,6 +30,7 @@ import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; +import java.time.chrono.IsoChronology; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.format.ResolverStyle; @@ -51,12 +53,12 @@ import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; public class DateFormatters { - public static final WeekFields WEEK_FIELDS = WeekFields.of(Locale.ROOT); + public static final WeekFields WEEK_FIELDS = WeekFields.of(DayOfWeek.MONDAY,4); private static final DateTimeFormatter TIME_ZONE_FORMATTER_NO_COLON = new DateTimeFormatterBuilder() .appendOffset("+HHmm", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter STRICT_YEAR_MONTH_DAY_FORMATTER = new DateTimeFormatterBuilder() .appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD) @@ -69,7 +71,7 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter STRICT_HOUR_MINUTE_SECOND_FORMATTER = new DateTimeFormatterBuilder() @@ -79,7 +81,7 @@ public class DateFormatters { .appendLiteral(':') .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter STRICT_DATE_OPTIONAL_TIME_PRINTER = new DateTimeFormatterBuilder() .append(STRICT_YEAR_MONTH_DAY_FORMATTER) @@ -102,7 +104,7 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter STRICT_DATE_OPTIONAL_TIME_FORMATTER = new DateTimeFormatterBuilder() .append(STRICT_YEAR_MONTH_DAY_FORMATTER) @@ -134,7 +136,7 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /** * Returns a generic ISO datetime parser where the date is mandatory and the time is optional. @@ -162,7 +164,7 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter STRICT_DATE_OPTIONAL_TIME_PRINTER_NANOS = new DateTimeFormatterBuilder() .append(STRICT_YEAR_MONTH_DAY_FORMATTER) @@ -185,7 +187,7 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /** * Returns a generic ISO datetime parser where the date is mandatory and the time is optional with nanosecond resolution. @@ -229,7 +231,7 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT)); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); ///////////////////////////////////////// // @@ -245,7 +247,7 @@ public class DateFormatters { .appendValue(MINUTE_OF_HOUR, 2, 2, SignStyle.NOT_NEGATIVE) .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a basic formatter for a two digit hour of day, two digit minute @@ -254,12 +256,12 @@ public class DateFormatters { private static final DateFormatter BASIC_TIME_NO_MILLIS = new JavaDateFormatter("basic_time_no_millis", new DateTimeFormatterBuilder().append(BASIC_TIME_NO_MILLIS_BASE).appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(BASIC_TIME_NO_MILLIS_BASE).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(BASIC_TIME_NO_MILLIS_BASE).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); private static final DateTimeFormatter BASIC_TIME_FORMATTER = new DateTimeFormatterBuilder() @@ -268,7 +270,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 1, 9, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter BASIC_TIME_PRINTER = new DateTimeFormatterBuilder() .appendValue(HOUR_OF_DAY, 2, 2, SignStyle.NOT_NEGATIVE) @@ -276,7 +278,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 3, 3, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a basic formatter for a two digit hour of day, two digit minute @@ -286,21 +288,21 @@ public class DateFormatters { private static final DateFormatter BASIC_TIME = new JavaDateFormatter("basic_time", new DateTimeFormatterBuilder().append(BASIC_TIME_PRINTER).appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(BASIC_TIME_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(BASIC_TIME_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); private static final DateTimeFormatter BASIC_T_TIME_PRINTER = new DateTimeFormatterBuilder().appendLiteral("T").append(BASIC_TIME_PRINTER).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter BASIC_T_TIME_FORMATTER = new DateTimeFormatterBuilder().appendLiteral("T").append(BASIC_TIME_FORMATTER).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a basic formatter for a two digit hour of day, two digit minute @@ -309,9 +311,9 @@ public class DateFormatters { */ private static final DateFormatter BASIC_T_TIME = new JavaDateFormatter("basic_t_time", new DateTimeFormatterBuilder().append(BASIC_T_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(BASIC_T_TIME_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(BASIC_T_TIME_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON). toFormatter(Locale.ROOT) ); @@ -324,14 +326,14 @@ public class DateFormatters { private static final DateFormatter BASIC_T_TIME_NO_MILLIS = new JavaDateFormatter("basic_t_time_no_millis", new DateTimeFormatterBuilder().appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); private static final DateTimeFormatter BASIC_YEAR_MONTH_DAY_FORMATTER = new DateTimeFormatterBuilder() @@ -339,19 +341,19 @@ public class DateFormatters { .appendValue(MONTH_OF_YEAR, 2, 2, SignStyle.NOT_NEGATIVE) .appendValue(DAY_OF_MONTH, 2, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter BASIC_DATE_TIME_FORMATTER = new DateTimeFormatterBuilder() .append(BASIC_YEAR_MONTH_DAY_FORMATTER) .append(BASIC_T_TIME_FORMATTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter BASIC_DATE_TIME_PRINTER = new DateTimeFormatterBuilder() .append(BASIC_YEAR_MONTH_DAY_FORMATTER) .append(BASIC_T_TIME_PRINTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a basic formatter that combines a basic date and time, separated @@ -359,16 +361,16 @@ public class DateFormatters { */ private static final DateFormatter BASIC_DATE_TIME = new JavaDateFormatter("basic_date_time", new DateTimeFormatterBuilder().append(BASIC_DATE_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(BASIC_DATE_TIME_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(BASIC_DATE_TIME_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); private static final DateTimeFormatter BASIC_DATE_T = new DateTimeFormatterBuilder().append(BASIC_YEAR_MONTH_DAY_FORMATTER).appendLiteral("T").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a basic formatter that combines a basic date and time without millis, @@ -377,13 +379,13 @@ public class DateFormatters { private static final DateFormatter BASIC_DATE_TIME_NO_MILLIS = new JavaDateFormatter("basic_date_time_no_millis", new DateTimeFormatterBuilder().append(BASIC_DATE_T).append(BASIC_TIME_NO_MILLIS_BASE) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(BASIC_DATE_T).append(BASIC_TIME_NO_MILLIS_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(BASIC_DATE_T).append(BASIC_TIME_NO_MILLIS_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -400,13 +402,13 @@ public class DateFormatters { private static final DateFormatter BASIC_ORDINAL_DATE_TIME = new JavaDateFormatter("basic_ordinal_date_time", new DateTimeFormatterBuilder().appendPattern("yyyyDDD").append(BASIC_T_TIME_PRINTER) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().appendPattern("yyyyDDD").append(BASIC_T_TIME_FORMATTER) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().appendPattern("yyyyDDD").append(BASIC_T_TIME_FORMATTER) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); @@ -417,13 +419,13 @@ public class DateFormatters { private static final DateFormatter BASIC_ORDINAL_DATE_TIME_NO_MILLIS = new JavaDateFormatter("basic_ordinal_date_time_no_millis", new DateTimeFormatterBuilder().appendPattern("uuuuDDD").appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().appendPattern("uuuuDDD").appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().appendPattern("uuuuDDD").appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); private static final DateTimeFormatter BASIC_WEEK_DATE_FORMATTER = new DateTimeFormatterBuilder() @@ -432,7 +434,7 @@ public class DateFormatters { .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1, 2, SignStyle.NEVER) .appendValue(ChronoField.DAY_OF_WEEK) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); ///////////////////////////////////////// // @@ -452,7 +454,7 @@ public class DateFormatters { .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1, 2, SignStyle.NEVER) .appendValue(ChronoField.DAY_OF_WEEK) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter STRICT_BASIC_WEEK_DATE_PRINTER = new DateTimeFormatterBuilder() .parseStrict() @@ -461,7 +463,7 @@ public class DateFormatters { .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 2, 2, SignStyle.NEVER) .appendValue(ChronoField.DAY_OF_WEEK) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a basic formatter for a full date as four digit weekyear, two @@ -484,7 +486,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder() .append(STRICT_BASIC_WEEK_DATE_PRINTER) .appendLiteral("T") @@ -493,7 +495,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendZoneOrOffsetId() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder() .append(STRICT_BASIC_WEEK_DATE_PRINTER) .appendLiteral("T") @@ -502,7 +504,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -514,7 +516,7 @@ public class DateFormatters { .append(STRICT_BASIC_WEEK_DATE_PRINTER) .append(DateTimeFormatter.ofPattern("'T'HHmmss.SSSX", Locale.ROOT)) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder() .append(STRICT_BASIC_WEEK_DATE_FORMATTER) .appendLiteral("T") @@ -524,7 +526,7 @@ public class DateFormatters { .appendFraction(NANO_OF_SECOND, 1, 9, true) .appendZoneOrOffsetId() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder() .append(STRICT_BASIC_WEEK_DATE_FORMATTER) .appendLiteral("T") @@ -534,7 +536,7 @@ public class DateFormatters { .appendFraction(NANO_OF_SECOND, 1, 9, true) .append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -570,7 +572,7 @@ public class DateFormatters { .appendLiteral("-") .appendValue(MONTH_OF_YEAR, 2, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT)); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); /* * A strict formatter that formats or parses a year, such as '2011'. @@ -578,7 +580,7 @@ public class DateFormatters { private static final DateFormatter STRICT_YEAR = new JavaDateFormatter("strict_year", new DateTimeFormatterBuilder() .appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT)); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); /* * A strict formatter that formats or parses a hour, minute and second, such as '09:43:25'. @@ -593,7 +595,7 @@ public class DateFormatters { .appendFraction(NANO_OF_SECOND, 3, 9, true) .appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter STRICT_DATE_FORMATTER = new DateTimeFormatterBuilder() .append(STRICT_YEAR_MONTH_DAY_FORMATTER) @@ -603,7 +605,7 @@ public class DateFormatters { .appendFraction(NANO_OF_SECOND, 1, 9, true) .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a formatter that combines a full date and time, separated by a 'T' @@ -611,10 +613,10 @@ public class DateFormatters { */ private static final DateFormatter STRICT_DATE_TIME = new JavaDateFormatter("strict_date_time", STRICT_DATE_PRINTER, new DateTimeFormatterBuilder().append(STRICT_DATE_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(STRICT_DATE_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); private static final DateTimeFormatter STRICT_ORDINAL_DATE_TIME_NO_MILLIS_BASE = new DateTimeFormatterBuilder() @@ -624,7 +626,7 @@ public class DateFormatters { .appendLiteral('T') .append(STRICT_HOUR_MINUTE_SECOND_FORMATTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a formatter for a full ordinal date and time without millis, @@ -633,13 +635,13 @@ public class DateFormatters { private static final DateFormatter STRICT_ORDINAL_DATE_TIME_NO_MILLIS = new JavaDateFormatter("strict_ordinal_date_time_no_millis", new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_NO_MILLIS_BASE) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_NO_MILLIS_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_NO_MILLIS_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); private static final DateTimeFormatter STRICT_DATE_TIME_NO_MILLIS_FORMATTER = new DateTimeFormatterBuilder() @@ -647,7 +649,7 @@ public class DateFormatters { .appendLiteral('T') .append(STRICT_HOUR_MINUTE_SECOND_FORMATTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a formatter that combines a full date and time without millis, @@ -656,13 +658,13 @@ public class DateFormatters { private static final DateFormatter STRICT_DATE_TIME_NO_MILLIS = new JavaDateFormatter("strict_date_time_no_millis", new DateTimeFormatterBuilder().append(STRICT_DATE_TIME_NO_MILLIS_FORMATTER) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(STRICT_DATE_TIME_NO_MILLIS_FORMATTER) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(STRICT_DATE_TIME_NO_MILLIS_FORMATTER) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); // NOTE: this is not a strict formatter to retain the joda time based behaviour, even though it's named like this @@ -670,13 +672,13 @@ public class DateFormatters { .append(STRICT_HOUR_MINUTE_SECOND_FORMATTER) .appendFraction(NANO_OF_SECOND, 1, 9, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter STRICT_HOUR_MINUTE_SECOND_MILLIS_PRINTER = new DateTimeFormatterBuilder() .append(STRICT_HOUR_MINUTE_SECOND_FORMATTER) .appendFraction(NANO_OF_SECOND, 3, 3, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a formatter for a two digit hour of day, two digit minute of @@ -706,7 +708,7 @@ public class DateFormatters { .appendLiteral("T") .append(STRICT_HOUR_MINUTE_SECOND_MILLIS_PRINTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder() .append(STRICT_YEAR_MONTH_DAY_FORMATTER) .appendLiteral("T") @@ -714,7 +716,7 @@ public class DateFormatters { // this one here is lenient as well to retain joda time based bwc compatibility .appendFraction(NANO_OF_SECOND, 1, 9, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); private static final DateFormatter STRICT_DATE_HOUR_MINUTE_SECOND_MILLIS = new JavaDateFormatter( @@ -724,7 +726,7 @@ public class DateFormatters { .appendLiteral("T") .append(STRICT_HOUR_MINUTE_SECOND_MILLIS_PRINTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder() .append(STRICT_YEAR_MONTH_DAY_FORMATTER) .appendLiteral("T") @@ -732,7 +734,7 @@ public class DateFormatters { // this one here is lenient as well to retain joda time based bwc compatibility .appendFraction(NANO_OF_SECOND, 1, 9, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -760,7 +762,7 @@ public class DateFormatters { .appendFraction(NANO_OF_SECOND, 3, 9, true) .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter STRICT_ORDINAL_DATE_TIME_FORMATTER_BASE = new DateTimeFormatterBuilder() .appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD) @@ -774,7 +776,7 @@ public class DateFormatters { .appendFraction(NANO_OF_SECOND, 1, 9, true) .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a formatter for a full ordinal date and time, using a four @@ -783,13 +785,13 @@ public class DateFormatters { private static final DateFormatter STRICT_ORDINAL_DATE_TIME = new JavaDateFormatter("strict_ordinal_date_time", new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_PRINTER) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_FORMATTER_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_FORMATTER_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); // Note: milliseconds parsing is not strict, others are @@ -801,7 +803,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 1, 9, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter STRICT_TIME_PRINTER = new DateTimeFormatterBuilder() .appendValue(HOUR_OF_DAY, 2, 2, SignStyle.NOT_NEGATIVE) @@ -811,7 +813,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 3, 3, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a formatter for a two digit hour of day, two digit minute of @@ -820,12 +822,12 @@ public class DateFormatters { */ private static final DateFormatter STRICT_TIME = new JavaDateFormatter("strict_time", new DateTimeFormatterBuilder().append(STRICT_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(STRICT_TIME_FORMATTER_BASE).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(STRICT_TIME_FORMATTER_BASE).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -837,13 +839,13 @@ public class DateFormatters { new DateTimeFormatterBuilder().appendLiteral('T').append(STRICT_TIME_PRINTER) .appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().appendLiteral('T').append(STRICT_TIME_FORMATTER_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().appendLiteral('T').append(STRICT_TIME_FORMATTER_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); private static final DateTimeFormatter STRICT_TIME_NO_MILLIS_BASE = new DateTimeFormatterBuilder() @@ -853,7 +855,7 @@ public class DateFormatters { .appendLiteral(':') .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a formatter for a two digit hour of day, two digit minute of @@ -862,12 +864,12 @@ public class DateFormatters { private static final DateFormatter STRICT_TIME_NO_MILLIS = new JavaDateFormatter("strict_time_no_millis", new DateTimeFormatterBuilder().append(STRICT_TIME_NO_MILLIS_BASE).appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(STRICT_TIME_NO_MILLIS_BASE).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(STRICT_TIME_NO_MILLIS_BASE).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -878,13 +880,13 @@ public class DateFormatters { private static final DateFormatter STRICT_T_TIME_NO_MILLIS = new JavaDateFormatter("strict_t_time_no_millis", new DateTimeFormatterBuilder().appendLiteral("T").append(STRICT_TIME_NO_MILLIS_BASE) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().appendLiteral("T").append(STRICT_TIME_NO_MILLIS_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().appendLiteral("T").append(STRICT_TIME_NO_MILLIS_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); private static final DateTimeFormatter ISO_WEEK_DATE = new DateTimeFormatterBuilder() @@ -895,13 +897,13 @@ public class DateFormatters { .appendLiteral('-') .appendValue(DAY_OF_WEEK, 1) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter ISO_WEEK_DATE_T = new DateTimeFormatterBuilder() .append(ISO_WEEK_DATE) .appendLiteral('T') .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a formatter for a full date as four digit weekyear, two digit @@ -916,13 +918,13 @@ public class DateFormatters { private static final DateFormatter STRICT_WEEK_DATE_TIME_NO_MILLIS = new JavaDateFormatter("strict_week_date_time_no_millis", new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T) .append(STRICT_TIME_NO_MILLIS_BASE).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T) .append(STRICT_TIME_NO_MILLIS_BASE).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T) .append(STRICT_TIME_NO_MILLIS_BASE).append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -932,13 +934,13 @@ public class DateFormatters { private static final DateFormatter STRICT_WEEK_DATE_TIME = new JavaDateFormatter("strict_week_date_time", new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T) .append(STRICT_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T).append(STRICT_TIME_FORMATTER_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T).append(STRICT_TIME_FORMATTER_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -947,14 +949,14 @@ public class DateFormatters { private static final DateFormatter STRICT_WEEKYEAR = new JavaDateFormatter("strict_weekyear", new DateTimeFormatterBuilder() .appendValue(WEEK_FIELDS.weekBasedYear(), 4, 10, SignStyle.EXCEEDS_PAD) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT)); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); private static final DateTimeFormatter STRICT_WEEKYEAR_WEEK_FORMATTER = new DateTimeFormatterBuilder() .appendValue(WEEK_FIELDS.weekBasedYear(), 4, 10, SignStyle.EXCEEDS_PAD) .appendLiteral("-W") .appendValue(WEEK_FIELDS.weekOfWeekBasedYear(), 2, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a formatter for a four digit weekyear and two digit week of @@ -973,7 +975,7 @@ public class DateFormatters { .appendLiteral("-") .appendValue(WEEK_FIELDS.dayOfWeek()) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT)); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); /* * Returns a formatter that combines a full date, two digit hour of day, @@ -993,13 +995,13 @@ public class DateFormatters { .appendValue(MONTH_OF_YEAR, 2, 2, SignStyle.NOT_NEGATIVE) .appendValue(DAY_OF_MONTH, 2, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withZone(ZoneOffset.UTC), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE).withZone(ZoneOffset.UTC), new DateTimeFormatterBuilder() .appendValue(ChronoField.YEAR, 1, 4, SignStyle.NORMAL) .appendValue(MONTH_OF_YEAR, 1, 2, SignStyle.NOT_NEGATIVE) .appendValue(DAY_OF_MONTH, 1, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withZone(ZoneOffset.UTC) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE).withZone(ZoneOffset.UTC) ); private static final DateTimeFormatter STRICT_ORDINAL_DATE_FORMATTER = new DateTimeFormatterBuilder() @@ -1009,7 +1011,7 @@ public class DateFormatters { .appendValue(DAY_OF_YEAR, 3) .optionalStart() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a formatter for a full ordinal date, using a four @@ -1040,13 +1042,13 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter HOUR_MINUTE_FORMATTER = new DateTimeFormatterBuilder() .appendValue(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE) .appendLiteral(':') .appendValue(MINUTE_OF_HOUR, 1, 2, SignStyle.NOT_NEGATIVE) - .toFormatter(Locale.ROOT).withResolverStyle(ResolverStyle.STRICT); + .toFormatter(Locale.ROOT).withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * a date formatter with optional time, being very lenient, format is @@ -1079,14 +1081,14 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .optionalEnd() - .toFormatter(Locale.ROOT).withResolverStyle(ResolverStyle.STRICT)); + .toFormatter(Locale.ROOT).withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); private static final DateTimeFormatter HOUR_MINUTE_SECOND_FORMATTER = new DateTimeFormatterBuilder() .append(HOUR_MINUTE_FORMATTER) .appendLiteral(":") .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter HOUR_MINUTE_SECOND_MILLIS_FORMATTER = new DateTimeFormatterBuilder() .appendValue(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE) @@ -1096,7 +1098,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 1, 3, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter HOUR_MINUTE_SECOND_FRACTION_FORMATTER = new DateTimeFormatterBuilder() .appendValue(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE) @@ -1106,21 +1108,21 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 1, 9, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter ORDINAL_DATE_FORMATTER = new DateTimeFormatterBuilder() .appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD) .appendLiteral('-') .appendValue(DAY_OF_YEAR, 1, 3, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter ORDINAL_DATE_PRINTER = new DateTimeFormatterBuilder() .appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD) .appendLiteral('-') .appendValue(DAY_OF_YEAR, 3, 3, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a formatter for a full ordinal date, using a four @@ -1136,17 +1138,17 @@ public class DateFormatters { .appendLiteral(':') .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter T_TIME_NO_MILLIS_FORMATTER = new DateTimeFormatterBuilder().appendLiteral("T").append(TIME_NO_MILLIS_FORMATTER).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter TIME_PREFIX = new DateTimeFormatterBuilder() .append(TIME_NO_MILLIS_FORMATTER) .appendFraction(NANO_OF_SECOND, 1, 9, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter WEEK_DATE_FORMATTER = new DateTimeFormatterBuilder() .appendValue(IsoFields.WEEK_BASED_YEAR, 4, 10, SignStyle.EXCEEDS_PAD) @@ -1155,21 +1157,21 @@ public class DateFormatters { .appendLiteral('-') .appendValue(DAY_OF_WEEK, 1) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a formatter for a four digit weekyear. (YYYY) */ private static final DateFormatter WEEK_YEAR = new JavaDateFormatter("week_year", new DateTimeFormatterBuilder().appendValue(WEEK_FIELDS.weekBasedYear()).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT)); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); /* * Returns a formatter for a four digit year. (uuuu) */ private static final DateFormatter YEAR = new JavaDateFormatter("year", new DateTimeFormatterBuilder().appendValue(ChronoField.YEAR).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT)); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); /* * Returns a formatter that combines a full date and two digit hour of @@ -1182,7 +1184,7 @@ public class DateFormatters { .appendLiteral("T") .appendValue(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT)); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); /* * Returns a formatter that combines a full date, two digit hour of day, @@ -1196,13 +1198,13 @@ public class DateFormatters { .appendLiteral("T") .append(STRICT_HOUR_MINUTE_SECOND_MILLIS_PRINTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder() .append(DATE_FORMATTER) .appendLiteral("T") .append(HOUR_MINUTE_SECOND_MILLIS_FORMATTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT)); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); private static final DateFormatter DATE_HOUR_MINUTE_SECOND_FRACTION = new JavaDateFormatter("date_hour_minute_second_fraction", @@ -1211,13 +1213,13 @@ public class DateFormatters { .appendLiteral("T") .append(STRICT_HOUR_MINUTE_SECOND_MILLIS_PRINTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder() .append(DATE_FORMATTER) .appendLiteral("T") .append(HOUR_MINUTE_SECOND_FRACTION_FORMATTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT)); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); /* * Returns a formatter that combines a full date, two digit hour of day, @@ -1230,7 +1232,7 @@ public class DateFormatters { .appendLiteral("T") .append(HOUR_MINUTE_FORMATTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT)); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); /* * Returns a formatter that combines a full date, two digit hour of day, @@ -1244,7 +1246,7 @@ public class DateFormatters { .appendLiteral("T") .append(HOUR_MINUTE_SECOND_FORMATTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT)); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); private static final DateTimeFormatter DATE_TIME_FORMATTER = new DateTimeFormatterBuilder() .append(DATE_FORMATTER) @@ -1256,7 +1258,7 @@ public class DateFormatters { .appendFraction(NANO_OF_SECOND, 1, 9, true) .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a formatter that combines a full date and time, separated by a 'T' @@ -1266,10 +1268,10 @@ public class DateFormatters { STRICT_DATE_OPTIONAL_TIME_PRINTER, new DateTimeFormatterBuilder().append(DATE_TIME_FORMATTER).appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(DATE_TIME_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -1284,7 +1286,7 @@ public class DateFormatters { * of year, and two digit day of month (uuuu-MM-dd). */ private static final DateFormatter DATE = new JavaDateFormatter("date", - DateTimeFormatter.ISO_LOCAL_DATE.withResolverStyle(ResolverStyle.STRICT), + DateTimeFormatter.ISO_LOCAL_DATE.withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), DATE_FORMATTER); // only the formatter, nothing optional here @@ -1296,7 +1298,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendZoneId() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); private static final DateTimeFormatter DATE_TIME_PREFIX = new DateTimeFormatterBuilder() .append(DATE_FORMATTER) @@ -1307,7 +1309,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a formatter that combines a full date and time without millis, but with a timezone that can be optional @@ -1316,16 +1318,16 @@ public class DateFormatters { private static final DateFormatter DATE_TIME_NO_MILLIS = new JavaDateFormatter("date_time_no_millis", DATE_TIME_NO_MILLIS_PRINTER, new DateTimeFormatterBuilder().append(DATE_TIME_PREFIX).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(DATE_TIME_PREFIX).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(DATE_TIME_PREFIX) .optionalStart().appendZoneOrOffsetId().optionalEnd().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(DATE_TIME_PREFIX) .optionalStart().append(TIME_ZONE_FORMATTER_NO_COLON).optionalEnd().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -1356,7 +1358,7 @@ public class DateFormatters { .appendLiteral(":") .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -1365,7 +1367,7 @@ public class DateFormatters { private static final DateFormatter HOUR = new JavaDateFormatter("hour", DateTimeFormatter.ofPattern("HH", Locale.ROOT), new DateTimeFormatterBuilder().appendValue(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); private static final DateTimeFormatter ORDINAL_DATE_TIME_FORMATTER_BASE = new DateTimeFormatterBuilder() @@ -1378,7 +1380,7 @@ public class DateFormatters { .appendFraction(NANO_OF_SECOND, 1, 9, true) .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a formatter for a full ordinal date and time, using a four @@ -1387,13 +1389,13 @@ public class DateFormatters { private static final DateFormatter ORDINAL_DATE_TIME = new JavaDateFormatter("ordinal_date_time", new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_PRINTER) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(ORDINAL_DATE_TIME_FORMATTER_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(ORDINAL_DATE_TIME_FORMATTER_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); private static final DateTimeFormatter ORDINAL_DATE_TIME_NO_MILLIS_BASE = new DateTimeFormatterBuilder() @@ -1401,7 +1403,7 @@ public class DateFormatters { .appendLiteral('T') .append(HOUR_MINUTE_SECOND_FORMATTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); /* * Returns a formatter for a full ordinal date and time without millis, @@ -1410,13 +1412,13 @@ public class DateFormatters { private static final DateFormatter ORDINAL_DATE_TIME_NO_MILLIS = new JavaDateFormatter("ordinal_date_time_no_millis", new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_NO_MILLIS_BASE) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(ORDINAL_DATE_TIME_NO_MILLIS_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(ORDINAL_DATE_TIME_NO_MILLIS_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -1426,13 +1428,13 @@ public class DateFormatters { private static final DateFormatter WEEK_DATE_TIME = new JavaDateFormatter("week_date_time", new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T) .append(STRICT_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(WEEK_DATE_FORMATTER).appendLiteral("T").append(TIME_PREFIX) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(WEEK_DATE_FORMATTER).appendLiteral("T").append(TIME_PREFIX) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -1442,13 +1444,13 @@ public class DateFormatters { private static final DateFormatter WEEK_DATE_TIME_NO_MILLIS = new JavaDateFormatter("week_date_time_no_millis", new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T) .append(STRICT_TIME_NO_MILLIS_BASE).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(WEEK_DATE_FORMATTER).append(T_TIME_NO_MILLIS_FORMATTER) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(WEEK_DATE_FORMATTER).append(T_TIME_NO_MILLIS_FORMATTER) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -1460,13 +1462,13 @@ public class DateFormatters { .append(STRICT_BASIC_WEEK_DATE_PRINTER) .append(DateTimeFormatter.ofPattern("'T'HHmmss.SSSX", Locale.ROOT)) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(BASIC_WEEK_DATE_FORMATTER).append(BASIC_T_TIME_FORMATTER) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(BASIC_WEEK_DATE_FORMATTER).append(BASIC_T_TIME_FORMATTER) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -1477,13 +1479,13 @@ public class DateFormatters { new DateTimeFormatterBuilder() .append(STRICT_BASIC_WEEK_DATE_PRINTER).append(DateTimeFormatter.ofPattern("'T'HHmmssX", Locale.ROOT)) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(BASIC_WEEK_DATE_FORMATTER).appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(BASIC_WEEK_DATE_FORMATTER).appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -1493,11 +1495,11 @@ public class DateFormatters { */ private static final DateFormatter TIME = new JavaDateFormatter("time", new DateTimeFormatterBuilder().append(STRICT_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(TIME_PREFIX).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(TIME_PREFIX).append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -1507,12 +1509,12 @@ public class DateFormatters { private static final DateFormatter TIME_NO_MILLIS = new JavaDateFormatter("time_no_millis", new DateTimeFormatterBuilder().append(STRICT_TIME_NO_MILLIS_BASE).appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(TIME_NO_MILLIS_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(TIME_NO_MILLIS_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -1523,13 +1525,13 @@ public class DateFormatters { private static final DateFormatter T_TIME = new JavaDateFormatter("t_time", new DateTimeFormatterBuilder().appendLiteral('T').append(STRICT_TIME_PRINTER).appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().appendLiteral("T").append(TIME_PREFIX) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().appendLiteral("T").append(TIME_PREFIX) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -1540,12 +1542,12 @@ public class DateFormatters { private static final DateFormatter T_TIME_NO_MILLIS = new JavaDateFormatter("t_time_no_millis", new DateTimeFormatterBuilder().appendLiteral("T").append(STRICT_TIME_NO_MILLIS_BASE) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(T_TIME_NO_MILLIS_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().append(T_TIME_NO_MILLIS_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -1557,10 +1559,10 @@ public class DateFormatters { .appendLiteral("-") .appendValue(MONTH_OF_YEAR, 2, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder().appendValue(ChronoField.YEAR).appendLiteral("-").appendValue(MONTH_OF_YEAR) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -1575,7 +1577,7 @@ public class DateFormatters { .appendLiteral("-") .appendValue(DAY_OF_MONTH) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -1594,7 +1596,7 @@ public class DateFormatters { .appendLiteral("-W") .appendValue(WEEK_FIELDS.weekOfWeekBasedYear()) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); /* @@ -1607,7 +1609,7 @@ public class DateFormatters { .appendLiteral("-") .appendValue(WEEK_FIELDS.dayOfWeek()) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT), + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), new DateTimeFormatterBuilder() .appendValue(WEEK_FIELDS.weekBasedYear()) .appendLiteral("-W") @@ -1615,7 +1617,7 @@ public class DateFormatters { .appendLiteral("-") .appendValue(WEEK_FIELDS.dayOfWeek()) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT) + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) ); ///////////////////////////////////////// @@ -1798,7 +1800,7 @@ static DateFormatter forPattern(String input) { return new JavaDateFormatter(input, new DateTimeFormatterBuilder() .appendPattern(input) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT)); + .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Invalid format: [" + input + "]: " + e.getMessage(), e); } diff --git a/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java b/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java index a048edcfb7091..73b73b58d9560 100644 --- a/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java +++ b/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.common.time; +import org.elasticsearch.bootstrap.JavaVersion; import org.elasticsearch.test.ESTestCase; import java.time.Clock; @@ -41,6 +42,8 @@ public class DateFormattersTests extends ESTestCase { public void testWeekBasedDates() { + assumeFalse("won't work in jdk8", JavaVersion.current().equals(JavaVersion.parse("8"))); + // as per WeekFields.ISO first week starts on Monday and has minimum 4 days DateFormatter dateFormatter = DateFormatters.forPattern("YYYY-ww"); diff --git a/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java b/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java index 8a4aacb6bbd19..1545f3712ec07 100644 --- a/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java +++ b/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.common.time; import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.bootstrap.JavaVersion; import org.elasticsearch.test.ESTestCase; import java.time.Instant; @@ -51,6 +52,8 @@ public void testOverridingLocaleOrZoneAndCompositeRoundUpParser() { } public void testWeekDates() { + assumeFalse("won't work in jdk8", JavaVersion.current().equals(JavaVersion.parse("8"))); + DateFormatter formatter = DateFormatter.forPattern("YYYY-ww"); assertDateMathEquals(formatter.toDateMathParser(), "2016-01", "2016-01-04T23:59:59.999Z", 0, true, ZoneOffset.UTC); diff --git a/test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java b/test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java index e035b779b3f02..61e1cb93a05c2 100644 --- a/test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java +++ b/test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java @@ -92,12 +92,12 @@ public class BootstrapForTesting { BootstrapInfo.getSystemProperties(); // check for jar hell - try { - final Logger logger = LogManager.getLogger(JarHell.class); - JarHell.checkJarHell(logger::debug); - } catch (Exception e) { - throw new RuntimeException("found jar hell in test classpath", e); - } +// try { +// final Logger logger = LogManager.getLogger(JarHell.class); +// JarHell.checkJarHell(logger::debug); +// } catch (Exception e) { +// throw new RuntimeException("found jar hell in test classpath", e); +// } // Log ifconfig output before SecurityManager is installed IfConfig.logIfNecessary(); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/filestructurefinder/TimestampFormatFinderTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/filestructurefinder/TimestampFormatFinderTests.java index 7c5d6833efbb2..8d232ab17f6dc 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/filestructurefinder/TimestampFormatFinderTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/filestructurefinder/TimestampFormatFinderTests.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.xpack.ml.filestructurefinder; +import org.elasticsearch.bootstrap.JavaVersion; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.time.DateFormatter; @@ -430,6 +431,8 @@ public void testGuessIsDayFirstFromMatchesMultipleFormats() { } public void testGuessIsDayFirstFromLocale() { + //TODO REVISIT THIS!! + assumeFalse("won't work in jdk8", JavaVersion.current().equals(JavaVersion.parse("8"))); TimestampFormatFinder timestampFormatFinder = new TimestampFormatFinder(explanation, true, true, true, NOOP_TIMEOUT_CHECKER); From d1e12e032016df6cf529de0054614c982a279005 Mon Sep 17 00:00:00 2001 From: Przemyslaw Gomulka Date: Tue, 22 Oct 2019 19:25:22 +0200 Subject: [PATCH 4/6] bootstra[ --- .../elasticsearch/bootstrap/BootstrapForTesting.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java b/test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java index 61e1cb93a05c2..e035b779b3f02 100644 --- a/test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java +++ b/test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java @@ -92,12 +92,12 @@ public class BootstrapForTesting { BootstrapInfo.getSystemProperties(); // check for jar hell -// try { -// final Logger logger = LogManager.getLogger(JarHell.class); -// JarHell.checkJarHell(logger::debug); -// } catch (Exception e) { -// throw new RuntimeException("found jar hell in test classpath", e); -// } + try { + final Logger logger = LogManager.getLogger(JarHell.class); + JarHell.checkJarHell(logger::debug); + } catch (Exception e) { + throw new RuntimeException("found jar hell in test classpath", e); + } // Log ifconfig output before SecurityManager is installed IfConfig.logIfNecessary(); From ce6e64c7e0da56323e280e0225b9eead9cb2ea63 Mon Sep 17 00:00:00 2001 From: Przemyslaw Gomulka Date: Wed, 23 Oct 2019 13:26:41 +0200 Subject: [PATCH 5/6] fixes --- .../elasticsearch/gradle/BuildPlugin.groovy | 8 +- distribution/src/config/jvm.options | 2 +- .../common/time/DateFormatters.java | 351 +++++++++--------- .../TimestampFormatFinderTests.java | 4 - 4 files changed, 182 insertions(+), 183 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index e681cc816bc5d..f34f59f1bef6d 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -842,6 +842,12 @@ class BuildPlugin implements Plugin { if ((ext.get('runtimeJavaVersion') as JavaVersion) >= JavaVersion.VERSION_1_9) { test.jvmArgs '--illegal-access=warn' } + //TODO remove once jvm.options are added to test system properties + if ((ext.get('runtimeJavaVersion') as JavaVersion) == JavaVersion.VERSION_1_8) { + test.systemProperty ('java.locale.providers','SPI,JRE') + } else if ((ext.get('runtimeJavaVersion') as JavaVersion) >= JavaVersion.VERSION_1_9) { + test.systemProperty ('java.locale.providers','SPI,COMPAT') + } } test.jvmArgumentProviders.add(nonInputProperties) @@ -876,8 +882,6 @@ class BuildPlugin implements Plugin { 'tests.security.manager': 'true', 'jna.nosys': 'true' - //TODO remove once jvm.options are added to test system properties - test.systemProperty ('java.locale.providers','SPI,COMPAT') // ignore changing test seed when build is passed -Dignore.tests.seed for cacheability experimentation if (System.getProperty('ignore.tests.seed') != null) { diff --git a/distribution/src/config/jvm.options b/distribution/src/config/jvm.options index ba5d4dae67a17..2fbc58ff860db 100644 --- a/distribution/src/config/jvm.options +++ b/distribution/src/config/jvm.options @@ -117,4 +117,4 @@ ${error.file} 9-:-Xlog:gc*,gc+age=trace,safepoint:file=${loggc}:utctime,pid,tags:filecount=32,filesize=64m # due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise # time/date parsing will break in an incompatible way for some date patterns and locals --Djava.locale.providers=SPI,COMPAT +9-:-Djava.locale.providers=COMPAT diff --git a/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java b/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java index b695a8834fdc8..26ec15559b803 100644 --- a/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java +++ b/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java @@ -30,7 +30,6 @@ import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; -import java.time.chrono.IsoChronology; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.format.ResolverStyle; @@ -58,7 +57,7 @@ public class DateFormatters { private static final DateTimeFormatter TIME_ZONE_FORMATTER_NO_COLON = new DateTimeFormatterBuilder() .appendOffset("+HHmm", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_YEAR_MONTH_DAY_FORMATTER = new DateTimeFormatterBuilder() .appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD) @@ -71,7 +70,7 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_HOUR_MINUTE_SECOND_FORMATTER = new DateTimeFormatterBuilder() @@ -81,7 +80,7 @@ public class DateFormatters { .appendLiteral(':') .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_DATE_OPTIONAL_TIME_PRINTER = new DateTimeFormatterBuilder() .append(STRICT_YEAR_MONTH_DAY_FORMATTER) @@ -104,7 +103,7 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_DATE_OPTIONAL_TIME_FORMATTER = new DateTimeFormatterBuilder() .append(STRICT_YEAR_MONTH_DAY_FORMATTER) @@ -136,7 +135,7 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /** * Returns a generic ISO datetime parser where the date is mandatory and the time is optional. @@ -164,7 +163,7 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_DATE_OPTIONAL_TIME_PRINTER_NANOS = new DateTimeFormatterBuilder() .append(STRICT_YEAR_MONTH_DAY_FORMATTER) @@ -187,7 +186,7 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /** * Returns a generic ISO datetime parser where the date is mandatory and the time is optional with nanosecond resolution. @@ -231,7 +230,7 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); + .withResolverStyle(ResolverStyle.STRICT)); ///////////////////////////////////////// // @@ -247,7 +246,7 @@ public class DateFormatters { .appendValue(MINUTE_OF_HOUR, 2, 2, SignStyle.NOT_NEGATIVE) .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a basic formatter for a two digit hour of day, two digit minute @@ -256,12 +255,12 @@ public class DateFormatters { private static final DateFormatter BASIC_TIME_NO_MILLIS = new JavaDateFormatter("basic_time_no_millis", new DateTimeFormatterBuilder().append(BASIC_TIME_NO_MILLIS_BASE).appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_TIME_NO_MILLIS_BASE).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_TIME_NO_MILLIS_BASE).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); private static final DateTimeFormatter BASIC_TIME_FORMATTER = new DateTimeFormatterBuilder() @@ -270,7 +269,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 1, 9, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter BASIC_TIME_PRINTER = new DateTimeFormatterBuilder() .appendValue(HOUR_OF_DAY, 2, 2, SignStyle.NOT_NEGATIVE) @@ -278,7 +277,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 3, 3, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a basic formatter for a two digit hour of day, two digit minute @@ -288,21 +287,21 @@ public class DateFormatters { private static final DateFormatter BASIC_TIME = new JavaDateFormatter("basic_time", new DateTimeFormatterBuilder().append(BASIC_TIME_PRINTER).appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_TIME_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_TIME_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); private static final DateTimeFormatter BASIC_T_TIME_PRINTER = new DateTimeFormatterBuilder().appendLiteral("T").append(BASIC_TIME_PRINTER).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter BASIC_T_TIME_FORMATTER = new DateTimeFormatterBuilder().appendLiteral("T").append(BASIC_TIME_FORMATTER).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a basic formatter for a two digit hour of day, two digit minute @@ -311,9 +310,9 @@ public class DateFormatters { */ private static final DateFormatter BASIC_T_TIME = new JavaDateFormatter("basic_t_time", new DateTimeFormatterBuilder().append(BASIC_T_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_T_TIME_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_T_TIME_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON). toFormatter(Locale.ROOT) ); @@ -326,14 +325,14 @@ public class DateFormatters { private static final DateFormatter BASIC_T_TIME_NO_MILLIS = new JavaDateFormatter("basic_t_time_no_millis", new DateTimeFormatterBuilder().appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); private static final DateTimeFormatter BASIC_YEAR_MONTH_DAY_FORMATTER = new DateTimeFormatterBuilder() @@ -341,19 +340,19 @@ public class DateFormatters { .appendValue(MONTH_OF_YEAR, 2, 2, SignStyle.NOT_NEGATIVE) .appendValue(DAY_OF_MONTH, 2, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter BASIC_DATE_TIME_FORMATTER = new DateTimeFormatterBuilder() .append(BASIC_YEAR_MONTH_DAY_FORMATTER) .append(BASIC_T_TIME_FORMATTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter BASIC_DATE_TIME_PRINTER = new DateTimeFormatterBuilder() .append(BASIC_YEAR_MONTH_DAY_FORMATTER) .append(BASIC_T_TIME_PRINTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a basic formatter that combines a basic date and time, separated @@ -361,16 +360,16 @@ public class DateFormatters { */ private static final DateFormatter BASIC_DATE_TIME = new JavaDateFormatter("basic_date_time", new DateTimeFormatterBuilder().append(BASIC_DATE_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_DATE_TIME_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_DATE_TIME_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); private static final DateTimeFormatter BASIC_DATE_T = new DateTimeFormatterBuilder().append(BASIC_YEAR_MONTH_DAY_FORMATTER).appendLiteral("T").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a basic formatter that combines a basic date and time without millis, @@ -379,13 +378,13 @@ public class DateFormatters { private static final DateFormatter BASIC_DATE_TIME_NO_MILLIS = new JavaDateFormatter("basic_date_time_no_millis", new DateTimeFormatterBuilder().append(BASIC_DATE_T).append(BASIC_TIME_NO_MILLIS_BASE) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_DATE_T).append(BASIC_TIME_NO_MILLIS_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_DATE_T).append(BASIC_TIME_NO_MILLIS_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -402,13 +401,13 @@ public class DateFormatters { private static final DateFormatter BASIC_ORDINAL_DATE_TIME = new JavaDateFormatter("basic_ordinal_date_time", new DateTimeFormatterBuilder().appendPattern("yyyyDDD").append(BASIC_T_TIME_PRINTER) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendPattern("yyyyDDD").append(BASIC_T_TIME_FORMATTER) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendPattern("yyyyDDD").append(BASIC_T_TIME_FORMATTER) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); @@ -419,13 +418,13 @@ public class DateFormatters { private static final DateFormatter BASIC_ORDINAL_DATE_TIME_NO_MILLIS = new JavaDateFormatter("basic_ordinal_date_time_no_millis", new DateTimeFormatterBuilder().appendPattern("uuuuDDD").appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendPattern("uuuuDDD").appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendPattern("uuuuDDD").appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); private static final DateTimeFormatter BASIC_WEEK_DATE_FORMATTER = new DateTimeFormatterBuilder() @@ -434,7 +433,7 @@ public class DateFormatters { .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1, 2, SignStyle.NEVER) .appendValue(ChronoField.DAY_OF_WEEK) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); ///////////////////////////////////////// // @@ -454,7 +453,7 @@ public class DateFormatters { .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1, 2, SignStyle.NEVER) .appendValue(ChronoField.DAY_OF_WEEK) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_BASIC_WEEK_DATE_PRINTER = new DateTimeFormatterBuilder() .parseStrict() @@ -463,7 +462,7 @@ public class DateFormatters { .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 2, 2, SignStyle.NEVER) .appendValue(ChronoField.DAY_OF_WEEK) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a basic formatter for a full date as four digit weekyear, two @@ -486,7 +485,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() .append(STRICT_BASIC_WEEK_DATE_PRINTER) .appendLiteral("T") @@ -495,7 +494,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendZoneOrOffsetId() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() .append(STRICT_BASIC_WEEK_DATE_PRINTER) .appendLiteral("T") @@ -504,7 +503,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -516,7 +515,7 @@ public class DateFormatters { .append(STRICT_BASIC_WEEK_DATE_PRINTER) .append(DateTimeFormatter.ofPattern("'T'HHmmss.SSSX", Locale.ROOT)) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() .append(STRICT_BASIC_WEEK_DATE_FORMATTER) .appendLiteral("T") @@ -526,7 +525,7 @@ public class DateFormatters { .appendFraction(NANO_OF_SECOND, 1, 9, true) .appendZoneOrOffsetId() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() .append(STRICT_BASIC_WEEK_DATE_FORMATTER) .appendLiteral("T") @@ -536,7 +535,7 @@ public class DateFormatters { .appendFraction(NANO_OF_SECOND, 1, 9, true) .append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -572,7 +571,7 @@ public class DateFormatters { .appendLiteral("-") .appendValue(MONTH_OF_YEAR, 2, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); + .withResolverStyle(ResolverStyle.STRICT)); /* * A strict formatter that formats or parses a year, such as '2011'. @@ -580,7 +579,7 @@ public class DateFormatters { private static final DateFormatter STRICT_YEAR = new JavaDateFormatter("strict_year", new DateTimeFormatterBuilder() .appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); + .withResolverStyle(ResolverStyle.STRICT)); /* * A strict formatter that formats or parses a hour, minute and second, such as '09:43:25'. @@ -595,7 +594,7 @@ public class DateFormatters { .appendFraction(NANO_OF_SECOND, 3, 9, true) .appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_DATE_FORMATTER = new DateTimeFormatterBuilder() .append(STRICT_YEAR_MONTH_DAY_FORMATTER) @@ -605,7 +604,7 @@ public class DateFormatters { .appendFraction(NANO_OF_SECOND, 1, 9, true) .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a formatter that combines a full date and time, separated by a 'T' @@ -613,10 +612,10 @@ public class DateFormatters { */ private static final DateFormatter STRICT_DATE_TIME = new JavaDateFormatter("strict_date_time", STRICT_DATE_PRINTER, new DateTimeFormatterBuilder().append(STRICT_DATE_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_DATE_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); private static final DateTimeFormatter STRICT_ORDINAL_DATE_TIME_NO_MILLIS_BASE = new DateTimeFormatterBuilder() @@ -626,7 +625,7 @@ public class DateFormatters { .appendLiteral('T') .append(STRICT_HOUR_MINUTE_SECOND_FORMATTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a formatter for a full ordinal date and time without millis, @@ -635,13 +634,13 @@ public class DateFormatters { private static final DateFormatter STRICT_ORDINAL_DATE_TIME_NO_MILLIS = new JavaDateFormatter("strict_ordinal_date_time_no_millis", new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_NO_MILLIS_BASE) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_NO_MILLIS_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_NO_MILLIS_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); private static final DateTimeFormatter STRICT_DATE_TIME_NO_MILLIS_FORMATTER = new DateTimeFormatterBuilder() @@ -649,7 +648,7 @@ public class DateFormatters { .appendLiteral('T') .append(STRICT_HOUR_MINUTE_SECOND_FORMATTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a formatter that combines a full date and time without millis, @@ -658,13 +657,13 @@ public class DateFormatters { private static final DateFormatter STRICT_DATE_TIME_NO_MILLIS = new JavaDateFormatter("strict_date_time_no_millis", new DateTimeFormatterBuilder().append(STRICT_DATE_TIME_NO_MILLIS_FORMATTER) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_DATE_TIME_NO_MILLIS_FORMATTER) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_DATE_TIME_NO_MILLIS_FORMATTER) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); // NOTE: this is not a strict formatter to retain the joda time based behaviour, even though it's named like this @@ -672,13 +671,13 @@ public class DateFormatters { .append(STRICT_HOUR_MINUTE_SECOND_FORMATTER) .appendFraction(NANO_OF_SECOND, 1, 9, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_HOUR_MINUTE_SECOND_MILLIS_PRINTER = new DateTimeFormatterBuilder() .append(STRICT_HOUR_MINUTE_SECOND_FORMATTER) .appendFraction(NANO_OF_SECOND, 3, 3, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a formatter for a two digit hour of day, two digit minute of @@ -708,7 +707,7 @@ public class DateFormatters { .appendLiteral("T") .append(STRICT_HOUR_MINUTE_SECOND_MILLIS_PRINTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() .append(STRICT_YEAR_MONTH_DAY_FORMATTER) .appendLiteral("T") @@ -716,7 +715,7 @@ public class DateFormatters { // this one here is lenient as well to retain joda time based bwc compatibility .appendFraction(NANO_OF_SECOND, 1, 9, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); private static final DateFormatter STRICT_DATE_HOUR_MINUTE_SECOND_MILLIS = new JavaDateFormatter( @@ -726,7 +725,7 @@ public class DateFormatters { .appendLiteral("T") .append(STRICT_HOUR_MINUTE_SECOND_MILLIS_PRINTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() .append(STRICT_YEAR_MONTH_DAY_FORMATTER) .appendLiteral("T") @@ -734,7 +733,7 @@ public class DateFormatters { // this one here is lenient as well to retain joda time based bwc compatibility .appendFraction(NANO_OF_SECOND, 1, 9, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -762,7 +761,7 @@ public class DateFormatters { .appendFraction(NANO_OF_SECOND, 3, 9, true) .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_ORDINAL_DATE_TIME_FORMATTER_BASE = new DateTimeFormatterBuilder() .appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD) @@ -776,7 +775,7 @@ public class DateFormatters { .appendFraction(NANO_OF_SECOND, 1, 9, true) .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a formatter for a full ordinal date and time, using a four @@ -785,13 +784,13 @@ public class DateFormatters { private static final DateFormatter STRICT_ORDINAL_DATE_TIME = new JavaDateFormatter("strict_ordinal_date_time", new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_PRINTER) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_FORMATTER_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_FORMATTER_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); // Note: milliseconds parsing is not strict, others are @@ -803,7 +802,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 1, 9, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_TIME_PRINTER = new DateTimeFormatterBuilder() .appendValue(HOUR_OF_DAY, 2, 2, SignStyle.NOT_NEGATIVE) @@ -813,7 +812,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 3, 3, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a formatter for a two digit hour of day, two digit minute of @@ -822,12 +821,12 @@ public class DateFormatters { */ private static final DateFormatter STRICT_TIME = new JavaDateFormatter("strict_time", new DateTimeFormatterBuilder().append(STRICT_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_TIME_FORMATTER_BASE).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_TIME_FORMATTER_BASE).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -839,13 +838,13 @@ public class DateFormatters { new DateTimeFormatterBuilder().appendLiteral('T').append(STRICT_TIME_PRINTER) .appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendLiteral('T').append(STRICT_TIME_FORMATTER_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendLiteral('T').append(STRICT_TIME_FORMATTER_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); private static final DateTimeFormatter STRICT_TIME_NO_MILLIS_BASE = new DateTimeFormatterBuilder() @@ -855,7 +854,7 @@ public class DateFormatters { .appendLiteral(':') .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a formatter for a two digit hour of day, two digit minute of @@ -864,12 +863,12 @@ public class DateFormatters { private static final DateFormatter STRICT_TIME_NO_MILLIS = new JavaDateFormatter("strict_time_no_millis", new DateTimeFormatterBuilder().append(STRICT_TIME_NO_MILLIS_BASE).appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_TIME_NO_MILLIS_BASE).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_TIME_NO_MILLIS_BASE).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -880,13 +879,13 @@ public class DateFormatters { private static final DateFormatter STRICT_T_TIME_NO_MILLIS = new JavaDateFormatter("strict_t_time_no_millis", new DateTimeFormatterBuilder().appendLiteral("T").append(STRICT_TIME_NO_MILLIS_BASE) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendLiteral("T").append(STRICT_TIME_NO_MILLIS_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendLiteral("T").append(STRICT_TIME_NO_MILLIS_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); private static final DateTimeFormatter ISO_WEEK_DATE = new DateTimeFormatterBuilder() @@ -897,13 +896,13 @@ public class DateFormatters { .appendLiteral('-') .appendValue(DAY_OF_WEEK, 1) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter ISO_WEEK_DATE_T = new DateTimeFormatterBuilder() .append(ISO_WEEK_DATE) .appendLiteral('T') .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a formatter for a full date as four digit weekyear, two digit @@ -918,13 +917,13 @@ public class DateFormatters { private static final DateFormatter STRICT_WEEK_DATE_TIME_NO_MILLIS = new JavaDateFormatter("strict_week_date_time_no_millis", new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T) .append(STRICT_TIME_NO_MILLIS_BASE).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T) .append(STRICT_TIME_NO_MILLIS_BASE).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T) .append(STRICT_TIME_NO_MILLIS_BASE).append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -934,13 +933,13 @@ public class DateFormatters { private static final DateFormatter STRICT_WEEK_DATE_TIME = new JavaDateFormatter("strict_week_date_time", new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T) .append(STRICT_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T).append(STRICT_TIME_FORMATTER_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T).append(STRICT_TIME_FORMATTER_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -949,14 +948,14 @@ public class DateFormatters { private static final DateFormatter STRICT_WEEKYEAR = new JavaDateFormatter("strict_weekyear", new DateTimeFormatterBuilder() .appendValue(WEEK_FIELDS.weekBasedYear(), 4, 10, SignStyle.EXCEEDS_PAD) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); + .withResolverStyle(ResolverStyle.STRICT)); private static final DateTimeFormatter STRICT_WEEKYEAR_WEEK_FORMATTER = new DateTimeFormatterBuilder() .appendValue(WEEK_FIELDS.weekBasedYear(), 4, 10, SignStyle.EXCEEDS_PAD) .appendLiteral("-W") .appendValue(WEEK_FIELDS.weekOfWeekBasedYear(), 2, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a formatter for a four digit weekyear and two digit week of @@ -975,7 +974,7 @@ public class DateFormatters { .appendLiteral("-") .appendValue(WEEK_FIELDS.dayOfWeek()) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); + .withResolverStyle(ResolverStyle.STRICT)); /* * Returns a formatter that combines a full date, two digit hour of day, @@ -995,13 +994,13 @@ public class DateFormatters { .appendValue(MONTH_OF_YEAR, 2, 2, SignStyle.NOT_NEGATIVE) .appendValue(DAY_OF_MONTH, 2, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE).withZone(ZoneOffset.UTC), + .withResolverStyle(ResolverStyle.STRICT).withZone(ZoneOffset.UTC), new DateTimeFormatterBuilder() .appendValue(ChronoField.YEAR, 1, 4, SignStyle.NORMAL) .appendValue(MONTH_OF_YEAR, 1, 2, SignStyle.NOT_NEGATIVE) .appendValue(DAY_OF_MONTH, 1, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE).withZone(ZoneOffset.UTC) + .withResolverStyle(ResolverStyle.STRICT).withZone(ZoneOffset.UTC) ); private static final DateTimeFormatter STRICT_ORDINAL_DATE_FORMATTER = new DateTimeFormatterBuilder() @@ -1011,7 +1010,7 @@ public class DateFormatters { .appendValue(DAY_OF_YEAR, 3) .optionalStart() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a formatter for a full ordinal date, using a four @@ -1042,13 +1041,13 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter HOUR_MINUTE_FORMATTER = new DateTimeFormatterBuilder() .appendValue(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE) .appendLiteral(':') .appendValue(MINUTE_OF_HOUR, 1, 2, SignStyle.NOT_NEGATIVE) - .toFormatter(Locale.ROOT).withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .toFormatter(Locale.ROOT).withResolverStyle(ResolverStyle.STRICT); /* * a date formatter with optional time, being very lenient, format is @@ -1081,14 +1080,14 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .optionalEnd() - .toFormatter(Locale.ROOT).withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); + .toFormatter(Locale.ROOT).withResolverStyle(ResolverStyle.STRICT)); private static final DateTimeFormatter HOUR_MINUTE_SECOND_FORMATTER = new DateTimeFormatterBuilder() .append(HOUR_MINUTE_FORMATTER) .appendLiteral(":") .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter HOUR_MINUTE_SECOND_MILLIS_FORMATTER = new DateTimeFormatterBuilder() .appendValue(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE) @@ -1098,7 +1097,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 1, 3, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter HOUR_MINUTE_SECOND_FRACTION_FORMATTER = new DateTimeFormatterBuilder() .appendValue(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE) @@ -1108,21 +1107,21 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 1, 9, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter ORDINAL_DATE_FORMATTER = new DateTimeFormatterBuilder() .appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD) .appendLiteral('-') .appendValue(DAY_OF_YEAR, 1, 3, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter ORDINAL_DATE_PRINTER = new DateTimeFormatterBuilder() .appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD) .appendLiteral('-') .appendValue(DAY_OF_YEAR, 3, 3, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a formatter for a full ordinal date, using a four @@ -1138,17 +1137,17 @@ public class DateFormatters { .appendLiteral(':') .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter T_TIME_NO_MILLIS_FORMATTER = new DateTimeFormatterBuilder().appendLiteral("T").append(TIME_NO_MILLIS_FORMATTER).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter TIME_PREFIX = new DateTimeFormatterBuilder() .append(TIME_NO_MILLIS_FORMATTER) .appendFraction(NANO_OF_SECOND, 1, 9, true) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter WEEK_DATE_FORMATTER = new DateTimeFormatterBuilder() .appendValue(IsoFields.WEEK_BASED_YEAR, 4, 10, SignStyle.EXCEEDS_PAD) @@ -1157,21 +1156,21 @@ public class DateFormatters { .appendLiteral('-') .appendValue(DAY_OF_WEEK, 1) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a formatter for a four digit weekyear. (YYYY) */ private static final DateFormatter WEEK_YEAR = new JavaDateFormatter("week_year", new DateTimeFormatterBuilder().appendValue(WEEK_FIELDS.weekBasedYear()).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); + .withResolverStyle(ResolverStyle.STRICT)); /* * Returns a formatter for a four digit year. (uuuu) */ private static final DateFormatter YEAR = new JavaDateFormatter("year", new DateTimeFormatterBuilder().appendValue(ChronoField.YEAR).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); + .withResolverStyle(ResolverStyle.STRICT)); /* * Returns a formatter that combines a full date and two digit hour of @@ -1184,7 +1183,7 @@ public class DateFormatters { .appendLiteral("T") .appendValue(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); + .withResolverStyle(ResolverStyle.STRICT)); /* * Returns a formatter that combines a full date, two digit hour of day, @@ -1198,13 +1197,13 @@ public class DateFormatters { .appendLiteral("T") .append(STRICT_HOUR_MINUTE_SECOND_MILLIS_PRINTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() .append(DATE_FORMATTER) .appendLiteral("T") .append(HOUR_MINUTE_SECOND_MILLIS_FORMATTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); + .withResolverStyle(ResolverStyle.STRICT)); private static final DateFormatter DATE_HOUR_MINUTE_SECOND_FRACTION = new JavaDateFormatter("date_hour_minute_second_fraction", @@ -1213,13 +1212,13 @@ public class DateFormatters { .appendLiteral("T") .append(STRICT_HOUR_MINUTE_SECOND_MILLIS_PRINTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() .append(DATE_FORMATTER) .appendLiteral("T") .append(HOUR_MINUTE_SECOND_FRACTION_FORMATTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); + .withResolverStyle(ResolverStyle.STRICT)); /* * Returns a formatter that combines a full date, two digit hour of day, @@ -1232,7 +1231,7 @@ public class DateFormatters { .appendLiteral("T") .append(HOUR_MINUTE_FORMATTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); + .withResolverStyle(ResolverStyle.STRICT)); /* * Returns a formatter that combines a full date, two digit hour of day, @@ -1246,7 +1245,7 @@ public class DateFormatters { .appendLiteral("T") .append(HOUR_MINUTE_SECOND_FORMATTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); + .withResolverStyle(ResolverStyle.STRICT)); private static final DateTimeFormatter DATE_TIME_FORMATTER = new DateTimeFormatterBuilder() .append(DATE_FORMATTER) @@ -1258,7 +1257,7 @@ public class DateFormatters { .appendFraction(NANO_OF_SECOND, 1, 9, true) .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a formatter that combines a full date and time, separated by a 'T' @@ -1268,10 +1267,10 @@ public class DateFormatters { STRICT_DATE_OPTIONAL_TIME_PRINTER, new DateTimeFormatterBuilder().append(DATE_TIME_FORMATTER).appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(DATE_TIME_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -1286,7 +1285,7 @@ public class DateFormatters { * of year, and two digit day of month (uuuu-MM-dd). */ private static final DateFormatter DATE = new JavaDateFormatter("date", - DateTimeFormatter.ISO_LOCAL_DATE.withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + DateTimeFormatter.ISO_LOCAL_DATE.withResolverStyle(ResolverStyle.STRICT), DATE_FORMATTER); // only the formatter, nothing optional here @@ -1298,7 +1297,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendZoneId() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter DATE_TIME_PREFIX = new DateTimeFormatterBuilder() .append(DATE_FORMATTER) @@ -1309,7 +1308,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a formatter that combines a full date and time without millis, but with a timezone that can be optional @@ -1318,16 +1317,16 @@ public class DateFormatters { private static final DateFormatter DATE_TIME_NO_MILLIS = new JavaDateFormatter("date_time_no_millis", DATE_TIME_NO_MILLIS_PRINTER, new DateTimeFormatterBuilder().append(DATE_TIME_PREFIX).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(DATE_TIME_PREFIX).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(DATE_TIME_PREFIX) .optionalStart().appendZoneOrOffsetId().optionalEnd().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(DATE_TIME_PREFIX) .optionalStart().append(TIME_ZONE_FORMATTER_NO_COLON).optionalEnd().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -1358,7 +1357,7 @@ public class DateFormatters { .appendLiteral(":") .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -1367,7 +1366,7 @@ public class DateFormatters { private static final DateFormatter HOUR = new JavaDateFormatter("hour", DateTimeFormatter.ofPattern("HH", Locale.ROOT), new DateTimeFormatterBuilder().appendValue(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); private static final DateTimeFormatter ORDINAL_DATE_TIME_FORMATTER_BASE = new DateTimeFormatterBuilder() @@ -1380,7 +1379,7 @@ public class DateFormatters { .appendFraction(NANO_OF_SECOND, 1, 9, true) .optionalEnd() .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a formatter for a full ordinal date and time, using a four @@ -1389,13 +1388,13 @@ public class DateFormatters { private static final DateFormatter ORDINAL_DATE_TIME = new JavaDateFormatter("ordinal_date_time", new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_PRINTER) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(ORDINAL_DATE_TIME_FORMATTER_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(ORDINAL_DATE_TIME_FORMATTER_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); private static final DateTimeFormatter ORDINAL_DATE_TIME_NO_MILLIS_BASE = new DateTimeFormatterBuilder() @@ -1403,7 +1402,7 @@ public class DateFormatters { .appendLiteral('T') .append(HOUR_MINUTE_SECOND_FORMATTER) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE); + .withResolverStyle(ResolverStyle.STRICT); /* * Returns a formatter for a full ordinal date and time without millis, @@ -1412,13 +1411,13 @@ public class DateFormatters { private static final DateFormatter ORDINAL_DATE_TIME_NO_MILLIS = new JavaDateFormatter("ordinal_date_time_no_millis", new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_NO_MILLIS_BASE) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(ORDINAL_DATE_TIME_NO_MILLIS_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(ORDINAL_DATE_TIME_NO_MILLIS_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -1428,13 +1427,13 @@ public class DateFormatters { private static final DateFormatter WEEK_DATE_TIME = new JavaDateFormatter("week_date_time", new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T) .append(STRICT_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(WEEK_DATE_FORMATTER).appendLiteral("T").append(TIME_PREFIX) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(WEEK_DATE_FORMATTER).appendLiteral("T").append(TIME_PREFIX) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -1444,13 +1443,13 @@ public class DateFormatters { private static final DateFormatter WEEK_DATE_TIME_NO_MILLIS = new JavaDateFormatter("week_date_time_no_millis", new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T) .append(STRICT_TIME_NO_MILLIS_BASE).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(WEEK_DATE_FORMATTER).append(T_TIME_NO_MILLIS_FORMATTER) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(WEEK_DATE_FORMATTER).append(T_TIME_NO_MILLIS_FORMATTER) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -1462,13 +1461,13 @@ public class DateFormatters { .append(STRICT_BASIC_WEEK_DATE_PRINTER) .append(DateTimeFormatter.ofPattern("'T'HHmmss.SSSX", Locale.ROOT)) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_WEEK_DATE_FORMATTER).append(BASIC_T_TIME_FORMATTER) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_WEEK_DATE_FORMATTER).append(BASIC_T_TIME_FORMATTER) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -1479,13 +1478,13 @@ public class DateFormatters { new DateTimeFormatterBuilder() .append(STRICT_BASIC_WEEK_DATE_PRINTER).append(DateTimeFormatter.ofPattern("'T'HHmmssX", Locale.ROOT)) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_WEEK_DATE_FORMATTER).appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_WEEK_DATE_FORMATTER).appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -1495,11 +1494,11 @@ public class DateFormatters { */ private static final DateFormatter TIME = new JavaDateFormatter("time", new DateTimeFormatterBuilder().append(STRICT_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(TIME_PREFIX).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(TIME_PREFIX).append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -1509,12 +1508,12 @@ public class DateFormatters { private static final DateFormatter TIME_NO_MILLIS = new JavaDateFormatter("time_no_millis", new DateTimeFormatterBuilder().append(STRICT_TIME_NO_MILLIS_BASE).appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(TIME_NO_MILLIS_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(TIME_NO_MILLIS_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -1525,13 +1524,13 @@ public class DateFormatters { private static final DateFormatter T_TIME = new JavaDateFormatter("t_time", new DateTimeFormatterBuilder().appendLiteral('T').append(STRICT_TIME_PRINTER).appendOffset("+HH:MM", "Z") .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendLiteral("T").append(TIME_PREFIX) .appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendLiteral("T").append(TIME_PREFIX) .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -1542,12 +1541,12 @@ public class DateFormatters { private static final DateFormatter T_TIME_NO_MILLIS = new JavaDateFormatter("t_time_no_millis", new DateTimeFormatterBuilder().appendLiteral("T").append(STRICT_TIME_NO_MILLIS_BASE) .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(T_TIME_NO_MILLIS_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(T_TIME_NO_MILLIS_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -1559,10 +1558,10 @@ public class DateFormatters { .appendLiteral("-") .appendValue(MONTH_OF_YEAR, 2, 2, SignStyle.NOT_NEGATIVE) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendValue(ChronoField.YEAR).appendLiteral("-").appendValue(MONTH_OF_YEAR) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -1577,7 +1576,7 @@ public class DateFormatters { .appendLiteral("-") .appendValue(DAY_OF_MONTH) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -1596,7 +1595,7 @@ public class DateFormatters { .appendLiteral("-W") .appendValue(WEEK_FIELDS.weekOfWeekBasedYear()) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); /* @@ -1609,7 +1608,7 @@ public class DateFormatters { .appendLiteral("-") .appendValue(WEEK_FIELDS.dayOfWeek()) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE), + .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() .appendValue(WEEK_FIELDS.weekBasedYear()) .appendLiteral("-W") @@ -1617,7 +1616,7 @@ public class DateFormatters { .appendLiteral("-") .appendValue(WEEK_FIELDS.dayOfWeek()) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE) + .withResolverStyle(ResolverStyle.STRICT) ); ///////////////////////////////////////// @@ -1800,7 +1799,7 @@ static DateFormatter forPattern(String input) { return new JavaDateFormatter(input, new DateTimeFormatterBuilder() .appendPattern(input) .toFormatter(Locale.ROOT) - .withResolverStyle(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE)); + .withResolverStyle(ResolverStyle.STRICT)); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Invalid format: [" + input + "]: " + e.getMessage(), e); } diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/filestructurefinder/TimestampFormatFinderTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/filestructurefinder/TimestampFormatFinderTests.java index 8d232ab17f6dc..a0327183a16bc 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/filestructurefinder/TimestampFormatFinderTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/filestructurefinder/TimestampFormatFinderTests.java @@ -5,7 +5,6 @@ */ package org.elasticsearch.xpack.ml.filestructurefinder; -import org.elasticsearch.bootstrap.JavaVersion; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.time.DateFormatter; @@ -431,9 +430,6 @@ public void testGuessIsDayFirstFromMatchesMultipleFormats() { } public void testGuessIsDayFirstFromLocale() { - //TODO REVISIT THIS!! - assumeFalse("won't work in jdk8", JavaVersion.current().equals(JavaVersion.parse("8"))); - TimestampFormatFinder timestampFormatFinder = new TimestampFormatFinder(explanation, true, true, true, NOOP_TIMEOUT_CHECKER); // Locale fallback is the only way to decide From 69e529a2d0a5809a4cbe00a1b152f5b2a7671248 Mon Sep 17 00:00:00 2001 From: Przemyslaw Gomulka Date: Wed, 23 Oct 2019 15:33:56 +0200 Subject: [PATCH 6/6] rephrase the assume message --- .../org/elasticsearch/common/time/DateFormattersTests.java | 4 +++- .../elasticsearch/common/time/JavaDateMathParserTests.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java b/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java index 73b73b58d9560..6b6c792d0a1d3 100644 --- a/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java +++ b/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java @@ -42,7 +42,9 @@ public class DateFormattersTests extends ESTestCase { public void testWeekBasedDates() { - assumeFalse("won't work in jdk8", JavaVersion.current().equals(JavaVersion.parse("8"))); + assumeFalse("won't work in jdk8 " + + "because SPI mechanism is not looking at classpath - needs ISOCalendarDataProvider in jre's ext/libs", + JavaVersion.current().equals(JavaVersion.parse("8"))); // as per WeekFields.ISO first week starts on Monday and has minimum 4 days DateFormatter dateFormatter = DateFormatters.forPattern("YYYY-ww"); diff --git a/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java b/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java index 1545f3712ec07..1852ef639a42d 100644 --- a/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java +++ b/server/src/test/java/org/elasticsearch/common/time/JavaDateMathParserTests.java @@ -52,7 +52,9 @@ public void testOverridingLocaleOrZoneAndCompositeRoundUpParser() { } public void testWeekDates() { - assumeFalse("won't work in jdk8", JavaVersion.current().equals(JavaVersion.parse("8"))); + assumeFalse("won't work in jdk8 " + + "because SPI mechanism is not looking at classpath - needs ISOCalendarDataProvider in jre's ext/libs", + JavaVersion.current().equals(JavaVersion.parse("8"))); DateFormatter formatter = DateFormatter.forPattern("YYYY-ww"); assertDateMathEquals(formatter.toDateMathParser(), "2016-01", "2016-01-04T23:59:59.999Z", 0, true, ZoneOffset.UTC);