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 2626
2727import java .text .SimpleDateFormat ;
2828import java .util .Date ;
29+ import java .util .Locale ;
2930import java .util .TimeZone ;
3031
3132/**
@@ -109,7 +110,7 @@ private static class CachedDate {
109110 private final long endOfCachedDate ;
110111
111112 private CachedDate (long epochTimestamp ) {
112- SimpleDateFormat dateFormat = new SimpleDateFormat ("yyyy-MM-dd" );
113+ SimpleDateFormat dateFormat = new SimpleDateFormat ("yyyy-MM-dd" , Locale . ROOT );
113114 dateFormat .setTimeZone (TimeZone .getTimeZone ("UTC" ));
114115 cachedDateIso = dateFormat .format (new Date (epochTimestamp ));
115116 startOfCachedDate = atStartOfDay (epochTimestamp );
Original file line number Diff line number Diff line change 3333import java .time .ZoneOffset ;
3434import java .time .format .DateTimeFormatter ;
3535import java .time .temporal .ChronoUnit ;
36+ import java .util .Locale ;
3637
3738import static org .assertj .core .api .Assertions .assertThat ;
3839
@@ -41,12 +42,25 @@ class TimestampSerializerTest {
4142 private TimestampSerializer dateSerializer ;
4243 private DateTimeFormatter dateTimeFormatter = DateTimeFormatter .ofPattern ("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" ).withZone (ZoneId .of ("UTC" ));
4344
44-
4545 @ BeforeEach
4646 void setUp () {
4747 dateSerializer = new TimestampSerializer ();
4848 }
4949
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+
5064 @ Test
5165 void testSerializeEpochTimestampAsIsoDateTime () {
5266 long timestamp = 0 ;
You can’t perform that action at this time.
0 commit comments