diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 346480b3d5ae5..b64ac3060d779 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -861,6 +861,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 f07ce2b08f438..5808e22780b3e 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 528589af3eb12..2002c97df8244 100644 --- a/distribution/src/config/jvm.options +++ b/distribution/src/config/jvm.options @@ -104,4 +104,4 @@ ${error.file} -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=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 65899c3c128cc..293be893d293a 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,10 +36,10 @@ 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; +import java.util.Locale; import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; @@ -52,10 +51,11 @@ 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") - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_YEAR_MONTH_DAY_FORMATTER = new DateTimeFormatterBuilder() @@ -68,7 +68,7 @@ public class DateFormatters { .appendValue(DAY_OF_MONTH, 2, 2, SignStyle.NOT_NEGATIVE) .optionalEnd() .optionalEnd() - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); @@ -78,7 +78,7 @@ public class DateFormatters { .appendValue(MINUTE_OF_HOUR, 2, 2, SignStyle.NOT_NEGATIVE) .appendLiteral(':') .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_DATE_OPTIONAL_TIME_PRINTER = new DateTimeFormatterBuilder() @@ -101,7 +101,7 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .optionalEnd() - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_DATE_OPTIONAL_TIME_FORMATTER = new DateTimeFormatterBuilder() @@ -133,7 +133,7 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .optionalEnd() - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /** @@ -161,7 +161,7 @@ public class DateFormatters { .append(TIME_ZONE_FORMATTER_NO_COLON) .optionalEnd() .optionalEnd() - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_DATE_OPTIONAL_TIME_PRINTER_NANOS = new DateTimeFormatterBuilder() @@ -184,7 +184,7 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .optionalEnd() - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /** @@ -228,7 +228,7 @@ public class DateFormatters { .append(TIME_ZONE_FORMATTER_NO_COLON) .optionalEnd() .optionalEnd() - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT)); ///////////////////////////////////////// @@ -244,7 +244,7 @@ public class DateFormatters { .appendValue(HOUR_OF_DAY, 2, 2, SignStyle.NOT_NEGATIVE) .appendValue(MINUTE_OF_HOUR, 2, 2, SignStyle.NOT_NEGATIVE) .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -253,12 +253,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(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), - new DateTimeFormatterBuilder().append(BASIC_TIME_NO_MILLIS_BASE).appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(BASIC_TIME_NO_MILLIS_BASE).appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_TIME_NO_MILLIS_BASE).append(TIME_ZONE_FORMATTER_NO_COLON) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -267,7 +267,7 @@ public class DateFormatters { .appendValue(MINUTE_OF_HOUR, 2, 2, SignStyle.NOT_NEGATIVE) .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 1, 9, true) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter BASIC_TIME_PRINTER = new DateTimeFormatterBuilder() @@ -275,7 +275,7 @@ public class DateFormatters { .appendValue(MINUTE_OF_HOUR, 2, 2, SignStyle.NOT_NEGATIVE) .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 3, 3, true) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -285,21 +285,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(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), - new DateTimeFormatterBuilder().append(BASIC_TIME_FORMATTER).appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(BASIC_TIME_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_TIME_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); private static final DateTimeFormatter BASIC_T_TIME_PRINTER = - new DateTimeFormatterBuilder().appendLiteral("T").append(BASIC_TIME_PRINTER).toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().appendLiteral("T").append(BASIC_TIME_PRINTER).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter BASIC_T_TIME_FORMATTER = - new DateTimeFormatterBuilder().appendLiteral("T").append(BASIC_TIME_FORMATTER).toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().appendLiteral("T").append(BASIC_TIME_FORMATTER).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -308,12 +308,12 @@ public class DateFormatters { * offset prefixed by 'T' ('T'HHmmss.SSSZ). */ private static final DateFormatter BASIC_T_TIME = new JavaDateFormatter("basic_t_time", - new DateTimeFormatterBuilder().append(BASIC_T_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(BASIC_T_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), - new DateTimeFormatterBuilder().append(BASIC_T_TIME_FORMATTER).appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(BASIC_T_TIME_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_T_TIME_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON). - toFormatter(IsoLocale.ROOT) + toFormatter(Locale.ROOT) ); /* @@ -323,14 +323,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(IsoLocale.ROOT) + .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) - .appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) .append(TIME_ZONE_FORMATTER_NO_COLON) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -338,19 +338,19 @@ public class DateFormatters { .appendValue(ChronoField.YEAR, 4, 4, SignStyle.NORMAL) .appendValue(MONTH_OF_YEAR, 2, 2, SignStyle.NOT_NEGATIVE) .appendValue(DAY_OF_MONTH, 2, 2, SignStyle.NOT_NEGATIVE) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .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(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .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(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -358,16 +358,16 @@ public class DateFormatters { * by a 'T' (uuuuMMdd'T'HHmmss.SSSZ). */ private static final DateFormatter BASIC_DATE_TIME = new JavaDateFormatter("basic_date_time", - new DateTimeFormatterBuilder().append(BASIC_DATE_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(BASIC_DATE_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), - new DateTimeFormatterBuilder().append(BASIC_DATE_TIME_FORMATTER).appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(BASIC_DATE_TIME_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), - new DateTimeFormatterBuilder().append(BASIC_DATE_TIME_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(BASIC_DATE_TIME_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); private static final DateTimeFormatter BASIC_DATE_T = - new DateTimeFormatterBuilder().append(BASIC_YEAR_MONTH_DAY_FORMATTER).appendLiteral("T").toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(BASIC_YEAR_MONTH_DAY_FORMATTER).appendLiteral("T").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -376,13 +376,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(IsoLocale.ROOT) + .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_DATE_T).append(BASIC_TIME_NO_MILLIS_BASE) - .appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_DATE_T).append(BASIC_TIME_NO_MILLIS_BASE) - .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -391,7 +391,7 @@ public class DateFormatters { * digit year and three digit dayOfYear (uuuuDDD). */ private static final DateFormatter BASIC_ORDINAL_DATE = new JavaDateFormatter("basic_ordinal_date", - DateTimeFormatter.ofPattern("uuuuDDD", IsoLocale.ROOT)); + DateTimeFormatter.ofPattern("uuuuDDD", Locale.ROOT)); /* * Returns a formatter for a full ordinal date and time, using a four @@ -399,13 +399,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(IsoLocale.ROOT) + .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendPattern("yyyyDDD").append(BASIC_T_TIME_FORMATTER) - .appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendPattern("yyyyDDD").append(BASIC_T_TIME_FORMATTER) - .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -416,13 +416,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(IsoLocale.ROOT) + .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendPattern("uuuuDDD").appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) - .appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendPattern("uuuuDDD").appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) - .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -431,7 +431,7 @@ public class DateFormatters { .appendLiteral("W") .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1, 2, SignStyle.NEVER) .appendValue(ChronoField.DAY_OF_WEEK) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); ///////////////////////////////////////// @@ -451,7 +451,7 @@ public class DateFormatters { .appendLiteral("W") .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1, 2, SignStyle.NEVER) .appendValue(ChronoField.DAY_OF_WEEK) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_BASIC_WEEK_DATE_PRINTER = new DateTimeFormatterBuilder() @@ -460,7 +460,7 @@ public class DateFormatters { .appendLiteral("W") .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 2, 2, SignStyle.NEVER) .appendValue(ChronoField.DAY_OF_WEEK) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -483,7 +483,7 @@ public class DateFormatters { .appendValue(MINUTE_OF_HOUR, 2, 2, SignStyle.NOT_NEGATIVE) .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendOffset("+HH:MM", "Z") - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() .append(STRICT_BASIC_WEEK_DATE_PRINTER) @@ -492,7 +492,7 @@ public class DateFormatters { .appendValue(MINUTE_OF_HOUR, 2, 2, SignStyle.NOT_NEGATIVE) .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendZoneOrOffsetId() - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() .append(STRICT_BASIC_WEEK_DATE_PRINTER) @@ -501,7 +501,7 @@ public class DateFormatters { .appendValue(MINUTE_OF_HOUR, 2, 2, SignStyle.NOT_NEGATIVE) .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .append(TIME_ZONE_FORMATTER_NO_COLON) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -512,8 +512,8 @@ public class DateFormatters { private static final DateFormatter STRICT_BASIC_WEEK_DATE_TIME = new JavaDateFormatter("strict_basic_week_date_time", new DateTimeFormatterBuilder() .append(STRICT_BASIC_WEEK_DATE_PRINTER) - .append(DateTimeFormatter.ofPattern("'T'HHmmss.SSSX", IsoLocale.ROOT)) - .toFormatter(IsoLocale.ROOT) + .append(DateTimeFormatter.ofPattern("'T'HHmmss.SSSX", Locale.ROOT)) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() .append(STRICT_BASIC_WEEK_DATE_FORMATTER) @@ -523,7 +523,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 1, 9, true) .appendZoneOrOffsetId() - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() .append(STRICT_BASIC_WEEK_DATE_FORMATTER) @@ -533,7 +533,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 1, 9, true) .append(TIME_ZONE_FORMATTER_NO_COLON) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -541,19 +541,19 @@ public class DateFormatters { * An ISO date formatter that formats or parses a date without an offset, such as '2011-12-03'. */ private static final DateFormatter STRICT_DATE = new JavaDateFormatter("strict_date", - DateTimeFormatter.ISO_LOCAL_DATE.withResolverStyle(ResolverStyle.LENIENT).withLocale(IsoLocale.ROOT)); + DateTimeFormatter.ISO_LOCAL_DATE.withResolverStyle(ResolverStyle.LENIENT).withLocale(Locale.ROOT)); /* * A date formatter that formats or parses a date plus an hour without an offset, such as '2011-12-03T01'. */ private static final DateFormatter STRICT_DATE_HOUR = new JavaDateFormatter("strict_date_hour", - DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH", IsoLocale.ROOT)); + DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH", Locale.ROOT)); /* * A date formatter that formats or parses a date plus an hour/minute without an offset, such as '2011-12-03T01:10'. */ private static final DateFormatter STRICT_DATE_HOUR_MINUTE = new JavaDateFormatter("strict_date_hour_minute", - DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm", IsoLocale.ROOT)); + DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm", Locale.ROOT)); /* * A strict date formatter that formats or parses a date without an offset, such as '2011-12-03'. @@ -569,7 +569,7 @@ public class DateFormatters { .appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD) .appendLiteral("-") .appendValue(MONTH_OF_YEAR, 2, 2, SignStyle.NOT_NEGATIVE) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT)); /* @@ -577,7 +577,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(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT)); /* @@ -592,7 +592,7 @@ public class DateFormatters { .append(STRICT_HOUR_MINUTE_SECOND_FORMATTER) .appendFraction(NANO_OF_SECOND, 3, 9, true) .appendOffset("+HH:MM", "Z") - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_DATE_FORMATTER = new DateTimeFormatterBuilder() @@ -602,7 +602,7 @@ public class DateFormatters { .optionalStart() .appendFraction(NANO_OF_SECOND, 1, 9, true) .optionalEnd() - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -610,10 +610,10 @@ public class DateFormatters { * (uuuu-MM-dd'T'HH:mm:ss.SSSZZ). */ private static final DateFormatter STRICT_DATE_TIME = new JavaDateFormatter("strict_date_time", STRICT_DATE_PRINTER, - new DateTimeFormatterBuilder().append(STRICT_DATE_FORMATTER).appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(STRICT_DATE_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_DATE_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -623,7 +623,7 @@ public class DateFormatters { .appendValue(DAY_OF_YEAR, 3, 3, SignStyle.NOT_NEGATIVE) .appendLiteral('T') .append(STRICT_HOUR_MINUTE_SECOND_FORMATTER) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -632,13 +632,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(IsoLocale.ROOT) + .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_NO_MILLIS_BASE) - .appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_NO_MILLIS_BASE) - .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -646,7 +646,7 @@ public class DateFormatters { .append(STRICT_YEAR_MONTH_DAY_FORMATTER) .appendLiteral('T') .append(STRICT_HOUR_MINUTE_SECOND_FORMATTER) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -655,13 +655,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(IsoLocale.ROOT) + .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_DATE_TIME_NO_MILLIS_FORMATTER) - .appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_DATE_TIME_NO_MILLIS_FORMATTER) - .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -669,13 +669,13 @@ public class DateFormatters { private static final DateTimeFormatter STRICT_HOUR_MINUTE_SECOND_MILLIS_FORMATTER = new DateTimeFormatterBuilder() .append(STRICT_HOUR_MINUTE_SECOND_FORMATTER) .appendFraction(NANO_OF_SECOND, 1, 9, true) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .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(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -705,7 +705,7 @@ public class DateFormatters { .append(STRICT_YEAR_MONTH_DAY_FORMATTER) .appendLiteral("T") .append(STRICT_HOUR_MINUTE_SECOND_MILLIS_PRINTER) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() .append(STRICT_YEAR_MONTH_DAY_FORMATTER) @@ -713,7 +713,7 @@ public class DateFormatters { .append(STRICT_HOUR_MINUTE_SECOND_FORMATTER) // this one here is lenient as well to retain joda time based bwc compatibility .appendFraction(NANO_OF_SECOND, 1, 9, true) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -723,7 +723,7 @@ public class DateFormatters { .append(STRICT_YEAR_MONTH_DAY_FORMATTER) .appendLiteral("T") .append(STRICT_HOUR_MINUTE_SECOND_MILLIS_PRINTER) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() .append(STRICT_YEAR_MONTH_DAY_FORMATTER) @@ -731,7 +731,7 @@ public class DateFormatters { .append(STRICT_HOUR_MINUTE_SECOND_FORMATTER) // this one here is lenient as well to retain joda time based bwc compatibility .appendFraction(NANO_OF_SECOND, 1, 9, true) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -739,14 +739,14 @@ public class DateFormatters { * Returns a formatter for a two digit hour of day. (HH) */ private static final DateFormatter STRICT_HOUR = - new JavaDateFormatter("strict_hour", DateTimeFormatter.ofPattern("HH", IsoLocale.ROOT)); + new JavaDateFormatter("strict_hour", DateTimeFormatter.ofPattern("HH", Locale.ROOT)); /* * Returns a formatter for a two digit hour of day and two digit minute of * hour. (HH:mm) */ private static final DateFormatter STRICT_HOUR_MINUTE = - new JavaDateFormatter("strict_hour_minute", DateTimeFormatter.ofPattern("HH:mm", IsoLocale.ROOT)); + new JavaDateFormatter("strict_hour_minute", DateTimeFormatter.ofPattern("HH:mm", Locale.ROOT)); private static final DateTimeFormatter STRICT_ORDINAL_DATE_TIME_PRINTER = new DateTimeFormatterBuilder() .appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD) @@ -759,7 +759,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 3, 9, true) .optionalEnd() - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_ORDINAL_DATE_TIME_FORMATTER_BASE = new DateTimeFormatterBuilder() @@ -773,7 +773,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 1, 9, true) .optionalEnd() - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -782,13 +782,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(IsoLocale.ROOT) + .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_FORMATTER_BASE) - .appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_ORDINAL_DATE_TIME_FORMATTER_BASE) - .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -800,7 +800,7 @@ public class DateFormatters { .appendLiteral(':') .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 1, 9, true) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter STRICT_TIME_PRINTER = new DateTimeFormatterBuilder() @@ -810,7 +810,7 @@ public class DateFormatters { .appendLiteral(':') .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 3, 3, true) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -819,12 +819,12 @@ public class DateFormatters { * time zone offset (HH:mm:ss.SSSZZ). */ private static final DateFormatter STRICT_TIME = new JavaDateFormatter("strict_time", - new DateTimeFormatterBuilder().append(STRICT_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(STRICT_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), - new DateTimeFormatterBuilder().append(STRICT_TIME_FORMATTER_BASE).appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(STRICT_TIME_FORMATTER_BASE).appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_TIME_FORMATTER_BASE).append(TIME_ZONE_FORMATTER_NO_COLON) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -836,13 +836,13 @@ public class DateFormatters { private static final DateFormatter STRICT_T_TIME = new JavaDateFormatter("strict_t_time", new DateTimeFormatterBuilder().appendLiteral('T').append(STRICT_TIME_PRINTER) .appendOffset("+HH:MM", "Z") - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendLiteral('T').append(STRICT_TIME_FORMATTER_BASE) - .appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendLiteral('T').append(STRICT_TIME_FORMATTER_BASE) - .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -852,7 +852,7 @@ public class DateFormatters { .appendValue(MINUTE_OF_HOUR, 2, 2, SignStyle.NOT_NEGATIVE) .appendLiteral(':') .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -861,12 +861,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(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), - new DateTimeFormatterBuilder().append(STRICT_TIME_NO_MILLIS_BASE).appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(STRICT_TIME_NO_MILLIS_BASE).appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(STRICT_TIME_NO_MILLIS_BASE).append(TIME_ZONE_FORMATTER_NO_COLON) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -877,13 +877,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(IsoLocale.ROOT) + .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendLiteral("T").append(STRICT_TIME_NO_MILLIS_BASE) - .appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendLiteral("T").append(STRICT_TIME_NO_MILLIS_BASE) - .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -894,13 +894,13 @@ public class DateFormatters { .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 2) .appendLiteral('-') .appendValue(DAY_OF_WEEK, 1) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter ISO_WEEK_DATE_T = new DateTimeFormatterBuilder() .append(ISO_WEEK_DATE) .appendLiteral('T') - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -915,13 +915,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(IsoLocale.ROOT) + .append(STRICT_TIME_NO_MILLIS_BASE).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T) - .append(STRICT_TIME_NO_MILLIS_BASE).appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .append(STRICT_TIME_NO_MILLIS_BASE).appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T) - .append(STRICT_TIME_NO_MILLIS_BASE).append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + .append(STRICT_TIME_NO_MILLIS_BASE).append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -931,13 +931,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(IsoLocale.ROOT) + .append(STRICT_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T).append(STRICT_TIME_FORMATTER_BASE) - .appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(ISO_WEEK_DATE_T).append(STRICT_TIME_FORMATTER_BASE) - .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -945,15 +945,15 @@ 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) - .toFormatter(IsoLocale.ROOT) + .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) - .toFormatter(IsoLocale.ROOT) + .appendValue(WEEK_FIELDS.weekOfWeekBasedYear(), 2, 2, SignStyle.NOT_NEGATIVE) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -971,8 +971,8 @@ public class DateFormatters { new DateTimeFormatterBuilder() .append(STRICT_WEEKYEAR_WEEK_FORMATTER) .appendLiteral("-") - .appendValue(WeekFields.ISO.dayOfWeek()) - .toFormatter(IsoLocale.ROOT) + .appendValue(WEEK_FIELDS.dayOfWeek()) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT)); /* @@ -981,7 +981,7 @@ public class DateFormatters { * minute. (uuuu-MM-dd'T'HH:mm:ss) */ private static final DateFormatter STRICT_DATE_HOUR_MINUTE_SECOND = new JavaDateFormatter("strict_date_hour_minute_second", - DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss", IsoLocale.ROOT)); + DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss", Locale.ROOT)); /* * A basic formatter for a full date as four digit year, two digit @@ -992,13 +992,13 @@ public class DateFormatters { .appendValue(ChronoField.YEAR, 4, 4, SignStyle.NORMAL) .appendValue(MONTH_OF_YEAR, 2, 2, SignStyle.NOT_NEGATIVE) .appendValue(DAY_OF_MONTH, 2, 2, SignStyle.NOT_NEGATIVE) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .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(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT).withZone(ZoneOffset.UTC) ); @@ -1008,7 +1008,7 @@ public class DateFormatters { .appendLiteral('-') .appendValue(DAY_OF_YEAR, 3) .optionalStart() - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -1039,14 +1039,14 @@ public class DateFormatters { .appendValue(DAY_OF_MONTH, 1, 2, SignStyle.NOT_NEGATIVE) .optionalEnd() .optionalEnd() - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .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(IsoLocale.ROOT).withResolverStyle(ResolverStyle.STRICT); + .toFormatter(Locale.ROOT).withResolverStyle(ResolverStyle.STRICT); /* * a date formatter with optional time, being very lenient, format is @@ -1079,13 +1079,13 @@ public class DateFormatters { .optionalEnd() .optionalEnd() .optionalEnd() - .toFormatter(IsoLocale.ROOT).withResolverStyle(ResolverStyle.STRICT)); + .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(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter HOUR_MINUTE_SECOND_MILLIS_FORMATTER = new DateTimeFormatterBuilder() @@ -1095,7 +1095,7 @@ public class DateFormatters { .appendLiteral(':') .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 1, 3, true) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter HOUR_MINUTE_SECOND_FRACTION_FORMATTER = new DateTimeFormatterBuilder() @@ -1105,21 +1105,21 @@ public class DateFormatters { .appendLiteral(':') .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 1, 9, true) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .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(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .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(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -1135,17 +1135,17 @@ public class DateFormatters { .appendValue(MINUTE_OF_HOUR, 1, 2, SignStyle.NOT_NEGATIVE) .appendLiteral(':') .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter T_TIME_NO_MILLIS_FORMATTER = - new DateTimeFormatterBuilder().appendLiteral("T").append(TIME_NO_MILLIS_FORMATTER).toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().appendLiteral("T").append(TIME_NO_MILLIS_FORMATTER).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter TIME_PREFIX = new DateTimeFormatterBuilder() .append(TIME_NO_MILLIS_FORMATTER) .appendFraction(NANO_OF_SECOND, 1, 9, true) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter WEEK_DATE_FORMATTER = new DateTimeFormatterBuilder() @@ -1154,21 +1154,21 @@ public class DateFormatters { .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1, 2, SignStyle.NOT_NEGATIVE) .appendLiteral('-') .appendValue(DAY_OF_WEEK, 1) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .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(WeekFields.ISO.weekBasedYear()).toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().appendValue(WEEK_FIELDS.weekBasedYear()).toFormatter(Locale.ROOT) .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(IsoLocale.ROOT) + new DateTimeFormatterBuilder().appendValue(ChronoField.YEAR).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT)); /* @@ -1176,12 +1176,12 @@ public class DateFormatters { * day. (uuuu-MM-dd'T'HH) */ private static final DateFormatter DATE_HOUR = new JavaDateFormatter("date_hour", - DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH", IsoLocale.ROOT), + DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH", Locale.ROOT), new DateTimeFormatterBuilder() .append(DATE_FORMATTER) .appendLiteral("T") .appendValue(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT)); /* @@ -1195,13 +1195,13 @@ public class DateFormatters { .append(STRICT_YEAR_MONTH_DAY_FORMATTER) .appendLiteral("T") .append(STRICT_HOUR_MINUTE_SECOND_MILLIS_PRINTER) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() .append(DATE_FORMATTER) .appendLiteral("T") .append(HOUR_MINUTE_SECOND_MILLIS_FORMATTER) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT)); private static final DateFormatter DATE_HOUR_MINUTE_SECOND_FRACTION = @@ -1210,13 +1210,13 @@ public class DateFormatters { .append(STRICT_YEAR_MONTH_DAY_FORMATTER) .appendLiteral("T") .append(STRICT_HOUR_MINUTE_SECOND_MILLIS_PRINTER) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder() .append(DATE_FORMATTER) .appendLiteral("T") .append(HOUR_MINUTE_SECOND_FRACTION_FORMATTER) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT)); /* @@ -1224,12 +1224,12 @@ public class DateFormatters { * and two digit minute of hour. (uuuu-MM-dd'T'HH:mm) */ private static final DateFormatter DATE_HOUR_MINUTE = new JavaDateFormatter("date_hour_minute", - DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm", IsoLocale.ROOT), + DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm", Locale.ROOT), new DateTimeFormatterBuilder() .append(DATE_FORMATTER) .appendLiteral("T") .append(HOUR_MINUTE_FORMATTER) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT)); /* @@ -1238,12 +1238,12 @@ public class DateFormatters { * minute. (uuuu-MM-dd'T'HH:mm:ss) */ private static final DateFormatter DATE_HOUR_MINUTE_SECOND = new JavaDateFormatter("date_hour_minute_second", - DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss", IsoLocale.ROOT), + DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss", Locale.ROOT), new DateTimeFormatterBuilder() .append(DATE_FORMATTER) .appendLiteral("T") .append(HOUR_MINUTE_SECOND_FORMATTER) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT)); private static final DateTimeFormatter DATE_TIME_FORMATTER = new DateTimeFormatterBuilder() @@ -1255,7 +1255,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 1, 9, true) .optionalEnd() - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -1265,10 +1265,10 @@ public class DateFormatters { private static final DateFormatter DATE_TIME = new JavaDateFormatter("date_time", STRICT_DATE_OPTIONAL_TIME_PRINTER, new DateTimeFormatterBuilder().append(DATE_TIME_FORMATTER).appendOffset("+HH:MM", "Z") - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(DATE_TIME_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1295,7 +1295,7 @@ public class DateFormatters { .appendLiteral(':') .appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE) .appendZoneId() - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); private static final DateTimeFormatter DATE_TIME_PREFIX = new DateTimeFormatterBuilder() @@ -1306,7 +1306,7 @@ public class DateFormatters { .appendLiteral(':') .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) .optionalEnd() - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -1315,16 +1315,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(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(DATE_TIME_PREFIX).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(DATE_TIME_PREFIX).append(TIME_ZONE_FORMATTER_NO_COLON) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(DATE_TIME_PREFIX) - .optionalStart().appendZoneOrOffsetId().optionalEnd().toFormatter(IsoLocale.ROOT) + .optionalStart().appendZoneOrOffsetId().optionalEnd().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(DATE_TIME_PREFIX) - .optionalStart().append(TIME_ZONE_FORMATTER_NO_COLON).optionalEnd().toFormatter(IsoLocale.ROOT) + .optionalStart().append(TIME_ZONE_FORMATTER_NO_COLON).optionalEnd().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1344,7 +1344,7 @@ public class DateFormatters { * hour. (HH:mm) */ private static final DateFormatter HOUR_MINUTE = - new JavaDateFormatter("hour_minute", DateTimeFormatter.ofPattern("HH:mm", IsoLocale.ROOT), HOUR_MINUTE_FORMATTER); + new JavaDateFormatter("hour_minute", DateTimeFormatter.ofPattern("HH:mm", Locale.ROOT), HOUR_MINUTE_FORMATTER); /* * A strict formatter that formats or parses a hour, minute and second, such as '09:43:25'. @@ -1355,7 +1355,7 @@ public class DateFormatters { .append(HOUR_MINUTE_FORMATTER) .appendLiteral(":") .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1363,8 +1363,8 @@ public class DateFormatters { * Returns a formatter for a two digit hour of day. (HH) */ private static final DateFormatter HOUR = new JavaDateFormatter("hour", - DateTimeFormatter.ofPattern("HH", IsoLocale.ROOT), - new DateTimeFormatterBuilder().appendValue(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE).toFormatter(IsoLocale.ROOT) + DateTimeFormatter.ofPattern("HH", Locale.ROOT), + new DateTimeFormatterBuilder().appendValue(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1377,7 +1377,7 @@ public class DateFormatters { .appendValue(SECOND_OF_MINUTE, 1, 2, SignStyle.NOT_NEGATIVE) .appendFraction(NANO_OF_SECOND, 1, 9, true) .optionalEnd() - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -1386,13 +1386,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(IsoLocale.ROOT) + .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(ORDINAL_DATE_TIME_FORMATTER_BASE) - .appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(ORDINAL_DATE_TIME_FORMATTER_BASE) - .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1400,7 +1400,7 @@ public class DateFormatters { .append(ORDINAL_DATE_FORMATTER) .appendLiteral('T') .append(HOUR_MINUTE_SECOND_FORMATTER) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT); /* @@ -1409,13 +1409,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(IsoLocale.ROOT) + .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(ORDINAL_DATE_TIME_NO_MILLIS_BASE) - .appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(ORDINAL_DATE_TIME_NO_MILLIS_BASE) - .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1425,13 +1425,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(IsoLocale.ROOT) + .append(STRICT_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(WEEK_DATE_FORMATTER).appendLiteral("T").append(TIME_PREFIX) - .appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(WEEK_DATE_FORMATTER).appendLiteral("T").append(TIME_PREFIX) - .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1441,13 +1441,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(IsoLocale.ROOT) + .append(STRICT_TIME_NO_MILLIS_BASE).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(WEEK_DATE_FORMATTER).append(T_TIME_NO_MILLIS_FORMATTER) - .appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(WEEK_DATE_FORMATTER).append(T_TIME_NO_MILLIS_FORMATTER) - .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1458,14 +1458,14 @@ public class DateFormatters { private static final DateFormatter BASIC_WEEK_DATE_TIME = new JavaDateFormatter("basic_week_date_time", new DateTimeFormatterBuilder() .append(STRICT_BASIC_WEEK_DATE_PRINTER) - .append(DateTimeFormatter.ofPattern("'T'HHmmss.SSSX", IsoLocale.ROOT)) - .toFormatter(IsoLocale.ROOT) + .append(DateTimeFormatter.ofPattern("'T'HHmmss.SSSX", Locale.ROOT)) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_WEEK_DATE_FORMATTER).append(BASIC_T_TIME_FORMATTER) - .appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_WEEK_DATE_FORMATTER).append(BASIC_T_TIME_FORMATTER) - .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1475,14 +1475,14 @@ public class DateFormatters { */ private static final DateFormatter BASIC_WEEK_DATE_TIME_NO_MILLIS = new JavaDateFormatter("basic_week_date_time_no_millis", new DateTimeFormatterBuilder() - .append(STRICT_BASIC_WEEK_DATE_PRINTER).append(DateTimeFormatter.ofPattern("'T'HHmmssX", IsoLocale.ROOT)) - .toFormatter(IsoLocale.ROOT) + .append(STRICT_BASIC_WEEK_DATE_PRINTER).append(DateTimeFormatter.ofPattern("'T'HHmmssX", Locale.ROOT)) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(BASIC_WEEK_DATE_FORMATTER).appendLiteral("T").append(BASIC_TIME_NO_MILLIS_BASE) - .appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .appendZoneOrOffsetId().toFormatter(Locale.ROOT) .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(IsoLocale.ROOT) + .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1492,11 +1492,11 @@ public class DateFormatters { * time zone offset (HH:mm:ss.SSSZZ). */ private static final DateFormatter TIME = new JavaDateFormatter("time", - new DateTimeFormatterBuilder().append(STRICT_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(STRICT_TIME_PRINTER).appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), - new DateTimeFormatterBuilder().append(TIME_PREFIX).appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(TIME_PREFIX).appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), - new DateTimeFormatterBuilder().append(TIME_PREFIX).append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(TIME_PREFIX).append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1506,12 +1506,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(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), - new DateTimeFormatterBuilder().append(TIME_NO_MILLIS_FORMATTER).appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(TIME_NO_MILLIS_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(TIME_NO_MILLIS_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1522,13 +1522,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(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendLiteral("T").append(TIME_PREFIX) - .appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + .appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendLiteral("T").append(TIME_PREFIX) - .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(IsoLocale.ROOT) + .append(TIME_ZONE_FORMATTER_NO_COLON).toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1539,12 +1539,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(IsoLocale.ROOT) + .appendOffset("+HH:MM", "Z").toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), - new DateTimeFormatterBuilder().append(T_TIME_NO_MILLIS_FORMATTER).appendZoneOrOffsetId().toFormatter(IsoLocale.ROOT) + new DateTimeFormatterBuilder().append(T_TIME_NO_MILLIS_FORMATTER).appendZoneOrOffsetId().toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().append(T_TIME_NO_MILLIS_FORMATTER).append(TIME_ZONE_FORMATTER_NO_COLON) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1556,10 +1556,10 @@ public class DateFormatters { .appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD) .appendLiteral("-") .appendValue(MONTH_OF_YEAR, 2, 2, SignStyle.NOT_NEGATIVE) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT), new DateTimeFormatterBuilder().appendValue(ChronoField.YEAR).appendLiteral("-").appendValue(MONTH_OF_YEAR) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1574,7 +1574,7 @@ public class DateFormatters { .appendValue(MONTH_OF_YEAR) .appendLiteral("-") .appendValue(DAY_OF_MONTH) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1590,10 +1590,10 @@ 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()) - .toFormatter(IsoLocale.ROOT) + .appendValue(WEEK_FIELDS.weekOfWeekBasedYear()) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1605,16 +1605,16 @@ public class DateFormatters { new DateTimeFormatterBuilder() .append(STRICT_WEEKYEAR_WEEK_FORMATTER) .appendLiteral("-") - .appendValue(WeekFields.ISO.dayOfWeek()) - .toFormatter(IsoLocale.ROOT) + .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()) - .toFormatter(IsoLocale.ROOT) + .appendValue(WEEK_FIELDS.dayOfWeek()) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT) ); @@ -1799,7 +1799,7 @@ public class DateFormatters { try { return new JavaDateFormatter(input, new DateTimeFormatterBuilder() .appendPattern(input) - .toFormatter(IsoLocale.ROOT) + .toFormatter(Locale.ROOT) .withResolverStyle(ResolverStyle.STRICT)); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Invalid format: [" + input + "]: " + e.getMessage(), e); @@ -1861,7 +1861,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); @@ -1871,19 +1871,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 @@ -1891,12 +1881,25 @@ 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. * This is to make it compatible with Joda behaviour */ - static final TemporalQuery LOCAL_DATE_QUERY = new TemporalQuery<>() { + static final TemporalQuery LOCAL_DATE_QUERY = new TemporalQuery() { @Override public LocalDate queryFrom(TemporalAccessor temporal) { if (temporal.isSupported(ChronoField.EPOCH_DAY)) { @@ -1918,15 +1921,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; } @@ -1938,6 +1943,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/EpochTime.java b/server/src/main/java/org/elasticsearch/common/time/EpochTime.java index 5875e8572aebb..22b29bd0edf45 100644 --- a/server/src/main/java/org/elasticsearch/common/time/EpochTime.java +++ b/server/src/main/java/org/elasticsearch/common/time/EpochTime.java @@ -125,13 +125,13 @@ public long getFrom(TemporalAccessor temporal) { .optionalStart() // optional is used so isSupported will be called when printing .appendFraction(NANOS_OF_SECOND, 0, 9, true) .optionalEnd() - .toFormatter(IsoLocale.ROOT); + .toFormatter(Locale.ROOT); // this supports seconds ending in dot private static final DateTimeFormatter SECONDS_FORMATTER2 = new DateTimeFormatterBuilder() .appendValue(SECONDS, 1, 19, SignStyle.NORMAL) .appendLiteral('.') - .toFormatter(IsoLocale.ROOT); + .toFormatter(Locale.ROOT); // this supports milliseconds without any fraction private static final DateTimeFormatter MILLISECONDS_FORMATTER1 = new DateTimeFormatterBuilder() @@ -139,13 +139,13 @@ public long getFrom(TemporalAccessor temporal) { .optionalStart() .appendFraction(NANOS_OF_MILLI, 0, 6, true) .optionalEnd() - .toFormatter(IsoLocale.ROOT); + .toFormatter(Locale.ROOT); // this supports milliseconds ending in dot private static final DateTimeFormatter MILLISECONDS_FORMATTER2 = new DateTimeFormatterBuilder() .append(MILLISECONDS_FORMATTER1) .appendLiteral('.') - .toFormatter(IsoLocale.ROOT); + .toFormatter(Locale.ROOT); static final DateFormatter SECONDS_FORMATTER = new JavaDateFormatter("epoch_second", SECONDS_FORMATTER1, builder -> builder.parseDefaulting(ChronoField.NANO_OF_SECOND, 999_999_999L), diff --git a/libs/core/src/main/java/org/elasticsearch/common/time/IsoLocale.java b/server/src/main/java/org/elasticsearch/common/time/IsoCalendarDataProvider.java similarity index 55% rename from libs/core/src/main/java/org/elasticsearch/common/time/IsoLocale.java rename to server/src/main/java/org/elasticsearch/common/time/IsoCalendarDataProvider.java index 4d6d37d92345e..36a93049adeb8 100644 --- a/libs/core/src/main/java/org/elasticsearch/common/time/IsoLocale.java +++ b/server/src/main/java/org/elasticsearch/common/time/IsoCalendarDataProvider.java @@ -18,23 +18,24 @@ */ package org.elasticsearch.common.time; +import java.util.Calendar; import java.util.Locale; +import java.util.spi.CalendarDataProvider; -/** - * Locale constants to be used across elasticsearch code base. - * java.util.Locale.ROOT should not be used as it defaults start of the week incorrectly to Sunday. - */ -public final class IsoLocale { - private IsoLocale() { - throw new UnsupportedOperationException(); +public class IsoCalendarDataProvider extends CalendarDataProvider { + + @Override + public int getFirstDayOfWeek(Locale locale) { + return Calendar.MONDAY; } - /** - * We want to use Locale.ROOT but with a start of the week as defined in ISO8601 to be compatible with the behaviour in joda-time - * https://github.com/elastic/elasticsearch/issues/42588 - * @see java.time.temporal.WeekFields#of(Locale) - */ - public static final Locale ROOT = new Locale.Builder() - .setLocale(Locale.ROOT) - .setUnicodeLocaleKeyword("fw", "mon").build(); + @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/index/mapper/DateFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java index 57bc296b081fe..cfd6fdcec7a25 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java @@ -43,7 +43,6 @@ import org.elasticsearch.common.time.DateFormatters; import org.elasticsearch.common.time.DateMathParser; import org.elasticsearch.common.time.DateUtils; -import org.elasticsearch.common.time.IsoLocale; import org.elasticsearch.common.util.LocaleUtils; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.support.XContentMapValues; @@ -136,7 +135,7 @@ public static class Builder extends FieldMapper.Builder { private Boolean coerce; - private Locale locale = IsoLocale.ROOT; + private Locale locale = Locale.ROOT; private String pattern; public Builder(String name, RangeType type) { @@ -424,7 +423,7 @@ && fieldType().dateTimeFormatter().pattern().equals(DateFieldMapper.DEFAULT_DATE } if (fieldType().rangeType == RangeType.DATE && (includeDefaults || (fieldType().dateTimeFormatter() != null - && fieldType().dateTimeFormatter().locale() != IsoLocale.ROOT))) { + && fieldType().dateTimeFormatter().locale() != Locale.ROOT))) { builder.field("locale", fieldType().dateTimeFormatter().locale()); } if (includeDefaults || coerce.explicit()) { 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 f54891f4e4d53..1ead658ba7165 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 e478b6dfcc499..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 @@ -115,7 +141,7 @@ public void testParsersWithMultipleInternalFormats() throws Exception { } public void testLocales() { - assertThat(DateFormatters.forPattern("strict_date_optional_time").locale(), is(IsoLocale.ROOT)); + assertThat(DateFormatters.forPattern("strict_date_optional_time").locale(), is(Locale.ROOT)); Locale locale = randomLocale(random()); assertThat(DateFormatters.forPattern("strict_date_optional_time").withLocale(locale).locale(), is(locale)); } 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 579cf297fedd4..4f7fad85326f4 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", "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 e289f565ea64c..6b375e7bf3464 100644 --- a/server/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java +++ b/server/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java @@ -1579,21 +1579,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/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/StringUtils.java b/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/StringUtils.java index c558766e88547..780fce2604c04 100644 --- a/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/StringUtils.java +++ b/x-pack/plugin/sql/sql-proto/src/main/java/org/elasticsearch/xpack/sql/proto/StringUtils.java @@ -6,8 +6,6 @@ package org.elasticsearch.xpack.sql.proto; -import org.elasticsearch.common.time.IsoLocale; - import java.sql.Timestamp; import java.time.Duration; import java.time.OffsetTime; @@ -15,6 +13,7 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; +import java.util.Locale; import java.util.Objects; import java.util.concurrent.TimeUnit; @@ -26,6 +25,7 @@ import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; public final class StringUtils { + public static final String EMPTY = ""; public static final DateTimeFormatter ISO_DATE_WITH_MILLIS = new DateTimeFormatterBuilder() @@ -39,7 +39,7 @@ public final class StringUtils { .appendValue(SECOND_OF_MINUTE, 2) .appendFraction(MILLI_OF_SECOND, 3, 3, true) .appendOffsetId() - .toFormatter(IsoLocale.ROOT); + .toFormatter(Locale.ROOT); public static final DateTimeFormatter ISO_DATE_WITH_NANOS = new DateTimeFormatterBuilder() .parseCaseInsensitive() @@ -52,7 +52,7 @@ public final class StringUtils { .appendValue(SECOND_OF_MINUTE, 2) .appendFraction(NANO_OF_SECOND, 3, 9, true) .appendOffsetId() - .toFormatter(IsoLocale.ROOT); + .toFormatter(Locale.ROOT); public static final DateTimeFormatter ISO_TIME_WITH_MILLIS = new DateTimeFormatterBuilder() .parseCaseInsensitive() @@ -63,7 +63,7 @@ public final class StringUtils { .appendValue(SECOND_OF_MINUTE, 2) .appendFraction(MILLI_OF_SECOND, 3, 3, true) .appendOffsetId() - .toFormatter(IsoLocale.ROOT); + .toFormatter(Locale.ROOT); private static final int SECONDS_PER_MINUTE = 60; private static final int SECONDS_PER_HOUR = SECONDS_PER_MINUTE * 60; diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/datetime/DateTimeField.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/datetime/DateTimeField.java index 60b3ec3c550f6..9cbb6ab7f2020 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/datetime/DateTimeField.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/datetime/DateTimeField.java @@ -5,13 +5,13 @@ */ package org.elasticsearch.xpack.sql.expression.function.scalar.datetime; -import org.elasticsearch.common.time.IsoLocale; import org.elasticsearch.xpack.sql.util.StringUtils; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.stream.Collectors; @@ -21,7 +21,7 @@ static Map initializeResolutionMap(D[] valu Map nameToPart = new HashMap<>(); for (D datePart : values) { - String lowerCaseName = datePart.name().toLowerCase(IsoLocale.ROOT); + String lowerCaseName = datePart.name().toLowerCase(Locale.ROOT); nameToPart.put(lowerCaseName, datePart); for (String alias : datePart.aliases()) { @@ -36,7 +36,7 @@ static List initializeValidValues(D[] values) } static D resolveMatch(Map resolutionMap, String possibleMatch) { - return resolutionMap.get(possibleMatch.toLowerCase(IsoLocale.ROOT)); + return resolutionMap.get(possibleMatch.toLowerCase(Locale.ROOT)); } static List findSimilar(Iterable similars, String match) { 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/analysis/analyzer/VerifierErrorMessagesTests.java b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/analysis/analyzer/VerifierErrorMessagesTests.java index c6be820bbcb49..cf9cf8d0ea77b 100644 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/analysis/analyzer/VerifierErrorMessagesTests.java +++ b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/analysis/analyzer/VerifierErrorMessagesTests.java @@ -5,7 +5,6 @@ */ package org.elasticsearch.xpack.sql.analysis.analyzer; -import org.elasticsearch.common.time.IsoLocale; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.sql.TestUtils; import org.elasticsearch.xpack.sql.analysis.index.EsIndex; @@ -30,6 +29,7 @@ import java.util.Arrays; import java.util.LinkedHashMap; +import java.util.Locale; import java.util.Map; import static java.util.Collections.emptyMap; @@ -587,7 +587,7 @@ public void testInvalidTypeForStringFunction_WithOneArgString() { } public void testInvalidTypeForStringFunction_WithOneArgNumeric() { - String functionName = randomFrom(Arrays.asList(Char.class, Space.class)).getSimpleName().toUpperCase(IsoLocale.ROOT); + String functionName = randomFrom(Arrays.asList(Char.class, Space.class)).getSimpleName().toUpperCase(Locale.ROOT); assertEquals("1:8: argument of [" + functionName + "('foo')] must be [integer], found value ['foo'] type [keyword]", error("SELECT " + functionName + "('foo')")); assertEquals("1:8: argument of [" + functionName + "(1.2)] must be [integer], found value [1.2] type [double]", @@ -619,7 +619,7 @@ public void testInvalidTypeForStringFunction_WithTwoArgs() { } public void testInvalidTypeForNumericFunction_WithTwoArgs() { - String functionName = randomFrom(Arrays.asList(Round.class, Truncate.class)).getSimpleName().toUpperCase(IsoLocale.ROOT); + String functionName = randomFrom(Arrays.asList(Round.class, Truncate.class)).getSimpleName().toUpperCase(Locale.ROOT); assertEquals("1:8: first argument of [" + functionName + "('foo', 2)] must be [numeric], found value ['foo'] type [keyword]", error("SELECT " + functionName + "('foo', 2)")); assertEquals("1:8: second argument of [" + functionName + "(1.2, 'bar')] must be [integer], found value ['bar'] type [keyword]", 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 +}