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