@@ -82,7 +82,7 @@ private static DateFormatter newDateFormatter(String format, DateTimeFormatter p
82
82
);
83
83
}
84
84
85
- public static final WeekFields WEEK_FIELDS_ROOT = WeekFields .of ( Locale . ROOT ) ;
85
+ public static final WeekFields WEEK_FIELDS_ROOT = WeekFields .ISO ;
86
86
87
87
private static final DateTimeFormatter TIME_ZONE_FORMATTER_NO_COLON = new DateTimeFormatterBuilder ().appendOffset ("+HHmm" , "Z" )
88
88
.toFormatter (Locale .ROOT )
@@ -2391,6 +2391,7 @@ public static ZonedDateTime from(TemporalAccessor accessor, Locale locale, ZoneI
2391
2391
boolean isLocalTimeSet = localTime != null ;
2392
2392
2393
2393
// the first two cases are the most common, so this allows us to exit early when parsing dates
2394
+ WeekFields localeWeekFields ;
2394
2395
if (isLocalDateSet && isLocalTimeSet ) {
2395
2396
return of (localDate , localTime , zoneId );
2396
2397
} else if (accessor .isSupported (ChronoField .INSTANT_SECONDS ) && accessor .isSupported (NANO_OF_SECOND )) {
@@ -2409,17 +2410,18 @@ public static ZonedDateTime from(TemporalAccessor accessor, Locale locale, ZoneI
2409
2410
} else if (accessor .isSupported (MONTH_OF_YEAR )) {
2410
2411
// missing year, falling back to the epoch and then filling
2411
2412
return getLocalDate (accessor , locale ).atStartOfDay (zoneId );
2412
- } else if (accessor .isSupported (WeekFields .of (locale ).weekBasedYear ())) {
2413
- return localDateFromWeekBasedDate (accessor , locale ).atStartOfDay (zoneId );
2413
+ } else if (accessor .isSupported (WeekFields .ISO .weekBasedYear ())) {
2414
+ return localDateFromWeekBasedDate (accessor , locale , WeekFields .ISO ).atStartOfDay (zoneId );
2415
+ } else if (accessor .isSupported ((localeWeekFields = WeekFields .of (locale )).weekBasedYear ())) {
2416
+ return localDateFromWeekBasedDate (accessor , locale , localeWeekFields ).atStartOfDay (zoneId );
2414
2417
}
2415
2418
2416
2419
// we should not reach this piece of code, everything being parsed we should be able to
2417
2420
// convert to a zoned date time! If not, we have to extend the above methods
2418
2421
throw new IllegalArgumentException ("temporal accessor [" + accessor + "] cannot be converted to zoned date time" );
2419
2422
}
2420
2423
2421
- private static LocalDate localDateFromWeekBasedDate (TemporalAccessor accessor , Locale locale ) {
2422
- WeekFields weekFields = WeekFields .of (locale );
2424
+ private static LocalDate localDateFromWeekBasedDate (TemporalAccessor accessor , Locale locale , WeekFields weekFields ) {
2423
2425
if (accessor .isSupported (weekFields .weekOfWeekBasedYear ())) {
2424
2426
return LocalDate .ofEpochDay (0 )
2425
2427
.with (weekFields .weekBasedYear (), accessor .get (weekFields .weekBasedYear ()))
@@ -2461,8 +2463,11 @@ public String toString() {
2461
2463
};
2462
2464
2463
2465
private static LocalDate getLocalDate (TemporalAccessor accessor , Locale locale ) {
2464
- if (accessor .isSupported (WeekFields .of (locale ).weekBasedYear ())) {
2465
- return localDateFromWeekBasedDate (accessor , locale );
2466
+ WeekFields localeWeekFields ;
2467
+ if (accessor .isSupported (WeekFields .ISO .weekBasedYear ())) {
2468
+ return localDateFromWeekBasedDate (accessor , locale , WeekFields .ISO );
2469
+ } else if (accessor .isSupported ((localeWeekFields = WeekFields .of (locale )).weekBasedYear ())) {
2470
+ return localDateFromWeekBasedDate (accessor , locale , localeWeekFields );
2466
2471
} else if (accessor .isSupported (MONTH_OF_YEAR )) {
2467
2472
int year = getYear (accessor );
2468
2473
if (accessor .isSupported (DAY_OF_MONTH )) {
0 commit comments