|
@@ -21,8 +21,10 @@ package org.elasticsearch.common.time;
|
|
|
|
|
|
import org.elasticsearch.test.ESTestCase;
|
|
|
|
|
|
+import java.time.Clock;
|
|
|
import java.time.Instant;
|
|
|
import java.time.ZoneId;
|
|
|
+import java.time.ZoneOffset;
|
|
|
import java.time.ZonedDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.temporal.ChronoField;
|
|
@@ -96,6 +98,8 @@ public class DateFormattersTests extends ESTestCase {
|
|
|
assertThat(e.getMessage(), is("failed to parse date field [1234.1234567890] with format [epoch_second]"));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
public void testEpochMilliParsersWithDifferentFormatters() {
|
|
|
DateFormatter formatter = DateFormatter.forPattern("strict_date_optional_time||epoch_millis");
|
|
|
TemporalAccessor accessor = formatter.parse("123");
|
|
@@ -248,4 +252,12 @@ public class DateFormattersTests extends ESTestCase {
|
|
|
assertThat(roundupParser.getLocale(), is(locale));
|
|
|
assertThat(formatter.locale(), is(locale));
|
|
|
}
|
|
|
+
|
|
|
+ public void test0MillisAreFormatted() {
|
|
|
+ DateFormatter formatter = DateFormatter.forPattern("strict_date_time");
|
|
|
+ Clock clock = Clock.fixed(ZonedDateTime.of(2019, 02, 8, 11, 43, 00, 0,
|
|
|
+ ZoneOffset.UTC).toInstant(), ZoneOffset.UTC);
|
|
|
+ String formatted = formatter.formatMillis(clock.millis());
|
|
|
+ assertThat(formatted, is("2019-02-08T11:43:00.000Z"));
|
|
|
+ }
|
|
|
}
|