File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
main/java/co/elastic/logging
test/java/co/elastic/logging Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 26
26
27
27
import java .text .SimpleDateFormat ;
28
28
import java .util .Date ;
29
+ import java .util .Locale ;
29
30
import java .util .TimeZone ;
30
31
31
32
/**
@@ -109,7 +110,7 @@ private static class CachedDate {
109
110
private final long endOfCachedDate ;
110
111
111
112
private CachedDate (long epochTimestamp ) {
112
- SimpleDateFormat dateFormat = new SimpleDateFormat ("yyyy-MM-dd" );
113
+ SimpleDateFormat dateFormat = new SimpleDateFormat ("yyyy-MM-dd" , Locale . ROOT );
113
114
dateFormat .setTimeZone (TimeZone .getTimeZone ("UTC" ));
114
115
cachedDateIso = dateFormat .format (new Date (epochTimestamp ));
115
116
startOfCachedDate = atStartOfDay (epochTimestamp );
Original file line number Diff line number Diff line change 33
33
import java .time .ZoneOffset ;
34
34
import java .time .format .DateTimeFormatter ;
35
35
import java .time .temporal .ChronoUnit ;
36
+ import java .util .Locale ;
36
37
37
38
import static org .assertj .core .api .Assertions .assertThat ;
38
39
@@ -41,12 +42,25 @@ class TimestampSerializerTest {
41
42
private TimestampSerializer dateSerializer ;
42
43
private DateTimeFormatter dateTimeFormatter = DateTimeFormatter .ofPattern ("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" ).withZone (ZoneId .of ("UTC" ));
43
44
44
-
45
45
@ BeforeEach
46
46
void setUp () {
47
47
dateSerializer = new TimestampSerializer ();
48
48
}
49
49
50
+ @ Test
51
+ public void testSerializeWithCustomLocale () throws InterruptedException {
52
+ Locale .setDefault (new Locale .Builder ()
53
+ .setLanguage ("uz" )
54
+ .setRegion ("UZ" )
55
+ .setScript ("Cyrl" )
56
+ .build ());
57
+
58
+ dateSerializer = new TimestampSerializer ();
59
+
60
+ long timestamp = Instant .now ().toEpochMilli ();
61
+ assertDateFormattingIsCorrect (Instant .ofEpochMilli (timestamp ));
62
+ }
63
+
50
64
@ Test
51
65
void testSerializeEpochTimestampAsIsoDateTime () {
52
66
long timestamp = 0 ;
You can’t perform that action at this time.
0 commit comments