@@ -41,7 +41,7 @@ class ToCharFormatter {
41
41
of ("HH12" ).formatFn ("hh" ).numeric (),
42
42
of ("HH24" ).formatFn ("HH" ).numeric (),
43
43
of ("MI" ).formatFn ("mm" ).numeric (),
44
- of ("SS" ).formatFn ("s" , x -> String .format (Locale .ROOT , "%02d" , parseInt (x ))).numeric (),
44
+ of ("SS" ).formatFn ("s" , x -> String .format (Locale .ENGLISH , "%02d" , parseInt (x ))).numeric (),
45
45
of ("MS" ).formatFn ("n" , nano -> firstDigitsOfNanos (nano , 3 )).numericWithLeadingZeros (),
46
46
of ("US" ).formatFn ("n" , nano -> firstDigitsOfNanos (nano , 6 )).numericWithLeadingZeros (),
47
47
of ("FF1" ).formatFn ("n" , nano -> firstDigitsOfNanos (nano , 1 )).numericWithLeadingZeros (),
@@ -52,14 +52,14 @@ class ToCharFormatter {
52
52
of ("FF6" ).formatFn ("n" , nano -> firstDigitsOfNanos (nano , 6 )).numericWithLeadingZeros (),
53
53
of ("SSSSS" ).formatFn ("A" , milliSecondOfDay -> String .valueOf (parseInt (milliSecondOfDay ) / 1000 )).numeric (),
54
54
of ("SSSS" ).formatFn ("A" , milliSecondOfDay -> String .valueOf (parseInt (milliSecondOfDay ) / 1000 )).numeric (),
55
- of ("AM" ).formatFn ("a" , x -> x .toUpperCase (Locale .ROOT )).text (),
56
- of ("am" ).formatFn ("a" , x -> x .toLowerCase (Locale .ROOT )).text (),
57
- of ("PM" ).formatFn ("a" , x -> x .toUpperCase (Locale .ROOT )).text (),
58
- of ("pm" ).formatFn ("a" , x -> x .toLowerCase (Locale .ROOT )).text (),
55
+ of ("AM" ).formatFn ("a" , x -> x .toUpperCase (Locale .ENGLISH )).text (),
56
+ of ("am" ).formatFn ("a" , x -> x .toLowerCase (Locale .ENGLISH )).text (),
57
+ of ("PM" ).formatFn ("a" , x -> x .toUpperCase (Locale .ENGLISH )).text (),
58
+ of ("pm" ).formatFn ("a" , x -> x .toLowerCase (Locale .ENGLISH )).text (),
59
59
of ("A.M." ).formatFn ("a" , x -> x .charAt (0 ) + "." + x .charAt (1 ) + "." ).text (),
60
- of ("a.m." ).formatFn ("a" , x -> (x .charAt (0 ) + "." + x .charAt (1 ) + "." ).toLowerCase (Locale .ROOT )).text (),
60
+ of ("a.m." ).formatFn ("a" , x -> (x .charAt (0 ) + "." + x .charAt (1 ) + "." ).toLowerCase (Locale .ENGLISH )).text (),
61
61
of ("P.M." ).formatFn ("a" , x -> x .charAt (0 ) + "." + x .charAt (1 ) + "." ).text (),
62
- of ("p.m." ).formatFn ("a" , x -> (x .charAt (0 ) + "." + x .charAt (1 ) + "." ).toLowerCase (Locale .ROOT )).text (),
62
+ of ("p.m." ).formatFn ("a" , x -> (x .charAt (0 ) + "." + x .charAt (1 ) + "." ).toLowerCase (Locale .ENGLISH )).text (),
63
63
of ("Y,YYY" ).formatFn ("yyyy" , year -> year .charAt (0 ) + "," + year .substring (1 )).numericWithLeadingZeros (),
64
64
of ("YYYY" ).formatFn ("yyyy" ).numeric (),
65
65
of ("YYY" ).formatFn ("yyyy" , year -> year .substring (1 )).numeric (),
@@ -70,51 +70,53 @@ class ToCharFormatter {
70
70
of ("IY" ).formatFn (t -> lastNCharacter (absoluteWeekBasedYear (t ), 2 )).numeric (),
71
71
of ("I" ).formatFn (t -> lastNCharacter (absoluteWeekBasedYear (t ), 1 )).numeric (),
72
72
of ("BC" ).formatFn ("G" ).text (),
73
- of ("bc" ).formatFn ("G" , x -> x .toLowerCase (Locale .ROOT )).text (),
73
+ of ("bc" ).formatFn ("G" , x -> x .toLowerCase (Locale .ENGLISH )).text (),
74
74
of ("AD" ).formatFn ("G" ).text (),
75
- of ("ad" ).formatFn ("G" , x -> x .toLowerCase (Locale .ROOT )).text (),
75
+ of ("ad" ).formatFn ("G" , x -> x .toLowerCase (Locale .ENGLISH )).text (),
76
76
of ("B.C." ).formatFn ("G" , x -> x .charAt (0 ) + "." + x .charAt (1 ) + "." ).text (),
77
- of ("b.c." ).formatFn ("G" , x -> (x .charAt (0 ) + "." + x .charAt (1 ) + "." ).toLowerCase (Locale .ROOT )).text (),
77
+ of ("b.c." ).formatFn ("G" , x -> (x .charAt (0 ) + "." + x .charAt (1 ) + "." ).toLowerCase (Locale .ENGLISH )).text (),
78
78
of ("A.D." ).formatFn ("G" , x -> x .charAt (0 ) + "." + x .charAt (1 ) + "." ).text (),
79
- of ("a.d." ).formatFn ("G" , x -> (x .charAt (0 ) + "." + x .charAt (1 ) + "." ).toLowerCase (Locale .ROOT )).text (),
80
- of ("MONTH" ).formatFn ("MMMM" , x -> String .format (Locale .ROOT , "%-9s" , x .toUpperCase (Locale .ROOT ))).text (),
81
- of ("Month" ).formatFn ("MMMM" , x -> String .format (Locale .ROOT , "%-9s" , x )).text (),
82
- of ("month" ).formatFn ("MMMM" , x -> String .format (Locale .ROOT , "%-9s" , x .toLowerCase (Locale .ROOT ))).text (),
83
- of ("MON" ).formatFn ("MMM" , x -> x .toUpperCase (Locale .ROOT )).text (),
79
+ of ("a.d." ).formatFn ("G" , x -> (x .charAt (0 ) + "." + x .charAt (1 ) + "." ).toLowerCase (Locale .ENGLISH )).text (),
80
+ of ("MONTH" ).formatFn ("MMMM" , x -> String .format (Locale .ENGLISH , "%-9s" , x .toUpperCase (Locale .ENGLISH ))).text (),
81
+ of ("Month" ).formatFn ("MMMM" , x -> String .format (Locale .ENGLISH , "%-9s" , x )).text (),
82
+ of ("month" ).formatFn ("MMMM" , x -> String .format (Locale .ENGLISH , "%-9s" , x .toLowerCase (Locale .ENGLISH ))).text (),
83
+ of ("MON" ).formatFn ("MMM" , x -> x .toUpperCase (Locale .ENGLISH )).text (),
84
84
of ("Mon" ).formatFn ("MMM" ).text (),
85
- of ("mon" ).formatFn ("MMM" , x -> x .toLowerCase (Locale .ROOT )).text (),
85
+ of ("mon" ).formatFn ("MMM" , x -> x .toLowerCase (Locale .ENGLISH )).text (),
86
86
of ("MM" ).formatFn ("MM" ).numeric (),
87
- of ("DAY" ).formatFn ("EEEE" , x -> String .format (Locale .ROOT , "%-9s" , x .toUpperCase (Locale .ROOT ))).text (),
88
- of ("Day" ).formatFn ("EEEE" , x -> String .format (Locale .ROOT , "%-9s" , x )).text (),
89
- of ("day" ).formatFn ("EEEE" , x -> String .format (Locale .ROOT , "%-9s" , x .toLowerCase (Locale .ROOT ))).text (),
90
- of ("DY" ).formatFn ("E" , x -> x .toUpperCase (Locale .ROOT )).text (),
87
+ of ("DAY" ).formatFn ("EEEE" , x -> String .format (Locale .ENGLISH , "%-9s" , x .toUpperCase (Locale .ENGLISH ))).text (),
88
+ of ("Day" ).formatFn ("EEEE" , x -> String .format (Locale .ENGLISH , "%-9s" , x )).text (),
89
+ of ("day" ).formatFn ("EEEE" , x -> String .format (Locale .ENGLISH , "%-9s" , x .toLowerCase (Locale .ENGLISH ))).text (),
90
+ of ("DY" ).formatFn ("E" , x -> x .toUpperCase (Locale .ENGLISH )).text (),
91
91
of ("Dy" ).formatFn ("E" ).text (),
92
- of ("dy" ).formatFn ("E" , x -> x .toLowerCase (Locale .ROOT )).text (),
92
+ of ("dy" ).formatFn ("E" , x -> x .toLowerCase (Locale .ENGLISH )).text (),
93
93
of ("DDD" ).formatFn ("DDD" ).numeric (),
94
94
of ("IDDD" ).formatFn (
95
95
t -> String .format (
96
- Locale .ROOT ,
96
+ Locale .ENGLISH ,
97
97
"%03d" ,
98
98
(t .get (WeekFields .ISO .weekOfWeekBasedYear ()) - 1 ) * 7 + t .get (ChronoField .DAY_OF_WEEK )
99
99
)
100
100
).numeric (),
101
- of ("DD" ).formatFn ("d" , x -> String .format (Locale .ROOT , "%02d" , parseInt (x ))).numeric (),
101
+ of ("DD" ).formatFn ("d" , x -> String .format (Locale .ENGLISH , "%02d" , parseInt (x ))).numeric (),
102
102
of ("ID" ).formatFn (t -> String .valueOf (t .get (ChronoField .DAY_OF_WEEK ))).numeric (),
103
103
of ("D" ).formatFn (t -> String .valueOf (t .get (WeekFields .SUNDAY_START .dayOfWeek ()))).numeric (),
104
104
of ("W" ).formatFn (t -> String .valueOf (t .get (ChronoField .ALIGNED_WEEK_OF_MONTH ))).numeric (),
105
- of ("WW" ).formatFn (t -> String .format (Locale .ROOT , "%02d" , t .get (ChronoField .ALIGNED_WEEK_OF_YEAR ))).numeric (),
106
- of ("IW" ).formatFn (t -> String .format (Locale .ROOT , "%02d" , t .get (WeekFields .ISO .weekOfWeekBasedYear ()))).numeric (),
105
+ of ("WW" ).formatFn (t -> String .format (Locale .ENGLISH , "%02d" , t .get (ChronoField .ALIGNED_WEEK_OF_YEAR ))).numeric (),
106
+ of ("IW" ).formatFn (t -> String .format (Locale .ENGLISH , "%02d" , t .get (WeekFields .ISO .weekOfWeekBasedYear ()))).numeric (),
107
107
of ("CC" ).formatFn (t -> {
108
108
int century = yearToCentury (t .get (ChronoField .YEAR ));
109
- return String .format (Locale .ROOT , century < 0 ? "%03d" : "%02d" , century );
109
+ return String .format (Locale .ENGLISH , century < 0 ? "%03d" : "%02d" , century );
110
110
}).numeric (),
111
111
of ("J" ).formatFn (t -> String .valueOf (t .getLong (JulianFields .JULIAN_DAY ))).numeric (),
112
112
of ("Q" ).formatFn ("Q" ).numeric (),
113
- of ("RM" ).formatFn ("MM" , month -> String .format (Locale .ROOT , "%-4s" , monthToRoman (parseInt (month )))).text (),
114
- of ("rm" ).formatFn ("MM" , month -> String .format (Locale .ROOT , "%-4s" , monthToRoman (parseInt (month )).toLowerCase (Locale .ROOT )))
115
- .text (),
113
+ of ("RM" ).formatFn ("MM" , month -> String .format (Locale .ENGLISH , "%-4s" , monthToRoman (parseInt (month )))).text (),
114
+ of ("rm" ).formatFn (
115
+ "MM" ,
116
+ month -> String .format (Locale .ENGLISH , "%-4s" , monthToRoman (parseInt (month )).toLowerCase (Locale .ENGLISH ))
117
+ ).text (),
116
118
of ("TZ" ).formatFn (ToCharFormatter ::zoneAbbreviationOf ).text (),
117
- of ("tz" ).formatFn (t -> zoneAbbreviationOf (t ).toLowerCase (Locale .ROOT )).text (),
119
+ of ("tz" ).formatFn (t -> zoneAbbreviationOf (t ).toLowerCase (Locale .ENGLISH )).text (),
118
120
of ("TZH" ).acceptsLowercase (false ).formatFn ("ZZ" , s -> s .substring (0 , 3 )).text (),
119
121
of ("TZM" ).acceptsLowercase (false ).formatFn ("ZZ" , s -> lastNCharacter (s , 2 )).text (),
120
122
of ("OF" ).acceptsLowercase (false ).formatFn ("ZZZZZ" , ToCharFormatter ::formatOffset ).offset ()
@@ -127,7 +129,7 @@ class ToCharFormatter {
127
129
// also index the lower case version of the patterns if accepted
128
130
for (ToCharFormatter formatter : formatters ) {
129
131
if (formatter .acceptsLowercase ) {
130
- formatterMap .putIfAbsent (formatter .pattern .toLowerCase (Locale .ROOT ), formatter );
132
+ formatterMap .putIfAbsent (formatter .pattern .toLowerCase (Locale .ENGLISH ), formatter );
131
133
}
132
134
}
133
135
FORMATTER_MAP = formatterMap ;
@@ -274,8 +276,8 @@ private static String appendOrdinalSuffix(String defaultSuffix, String s) {
274
276
// the Y,YYY pattern might can cause problems with the parsing, but thankfully the last 3
275
277
// characters is enough to calculate the suffix
276
278
int i = parseInt (lastNCharacter (s , 3 ));
277
- final boolean upperCase = defaultSuffix .equals (defaultSuffix .toUpperCase (Locale .ROOT ));
278
- return s + (upperCase ? ordinalSuffix (i ).toUpperCase (Locale .ROOT ) : ordinalSuffix (i ));
279
+ final boolean upperCase = defaultSuffix .equals (defaultSuffix .toUpperCase (Locale .ENGLISH ));
280
+ return s + (upperCase ? ordinalSuffix (i ).toUpperCase (Locale .ENGLISH ) : ordinalSuffix (i ));
279
281
} catch (NumberFormatException ex ) {
280
282
return s + defaultSuffix ;
281
283
}
@@ -312,19 +314,19 @@ private static String removeLeadingZerosFromOffset(String offset) {
312
314
private static String absoluteWeekBasedYear (TemporalAccessor t ) {
313
315
int year = t .get (IsoFields .WEEK_BASED_YEAR );
314
316
year = year > 0 ? year : -(year - 1 );
315
- return String .format (Locale .ROOT , "%04d" , year );
317
+ return String .format (Locale .ENGLISH , "%04d" , year );
316
318
}
317
319
318
320
private static String firstDigitsOfNanos (String nano , int digits ) {
319
- return String .format (Locale .ROOT , "%09d" , parseInt (nano )).substring (0 , digits );
321
+ return String .format (Locale .ENGLISH , "%09d" , parseInt (nano )).substring (0 , digits );
320
322
}
321
323
322
324
private static String lastNCharacter (String s , int n ) {
323
325
return s .substring (Math .max (0 , s .length () - n ));
324
326
}
325
327
326
328
private static String zoneAbbreviationOf (TemporalAccessor temporalAccessor ) {
327
- String zone = ZoneId .from (temporalAccessor ).getDisplayName (TextStyle .SHORT , Locale .ROOT );
329
+ String zone = ZoneId .from (temporalAccessor ).getDisplayName (TextStyle .SHORT , Locale .ENGLISH );
328
330
return "Z" .equals (zone ) ? "UTC" : zone ;
329
331
}
330
332
@@ -344,7 +346,7 @@ public Builder formatFn(final String javaPattern) {
344
346
345
347
public Builder formatFn (final String javaPattern , final Function <String , String > additionalMapper ) {
346
348
this .formatFn = temporalAccessor -> {
347
- String formatted = DateTimeFormatter .ofPattern (javaPattern != null ? javaPattern : "'" + pattern + "'" , Locale .ROOT )
349
+ String formatted = DateTimeFormatter .ofPattern (javaPattern != null ? javaPattern : "'" + pattern + "'" , Locale .ENGLISH )
348
350
.format (temporalAccessor );
349
351
return additionalMapper == null ? formatted : additionalMapper .apply (formatted );
350
352
};
0 commit comments