This formatter should allow parsing fraction of a second with minimum width of 1. The same is allowed for strict_date_optional_time closes #61357
This commit is contained in:
parent
244f1a60f9
commit
5534a60fa0
|
@ -159,11 +159,11 @@ public class DateFormatters {
|
|||
.appendLiteral('T')
|
||||
.append(STRICT_HOUR_MINUTE_SECOND_FORMATTER)
|
||||
.optionalStart()
|
||||
.appendFraction(NANO_OF_SECOND, 3, 9, true)
|
||||
.appendFraction(NANO_OF_SECOND, 1, 9, true)
|
||||
.optionalEnd()
|
||||
.optionalStart()
|
||||
.appendLiteral(',')
|
||||
.appendFraction(NANO_OF_SECOND, 3, 9, false)
|
||||
.appendFraction(NANO_OF_SECOND, 1, 9, false)
|
||||
.optionalEnd()
|
||||
.optionalStart()
|
||||
.appendZoneOrOffsetId()
|
||||
|
|
|
@ -145,6 +145,15 @@ public class DateFormattersTests extends ESTestCase {
|
|||
assertThat(first, is(second));
|
||||
}
|
||||
|
||||
public void testNanoOfSecondWidth() throws Exception {
|
||||
ZonedDateTime first = DateFormatters.from(
|
||||
DateFormatters.forPattern("strict_date_optional_time_nanos").parse("1970-01-01T00:00:00.1"));
|
||||
assertThat(first.getNano(), is(100000000));
|
||||
ZonedDateTime second = DateFormatters.from(
|
||||
DateFormatters.forPattern("strict_date_optional_time_nanos").parse("1970-01-01T00:00:00.000000001"));
|
||||
assertThat(second.getNano(), is(1));
|
||||
}
|
||||
|
||||
public void testLocales() {
|
||||
assertThat(DateFormatters.forPattern("strict_date_optional_time").locale(), is(Locale.ROOT));
|
||||
Locale locale = randomLocale(random());
|
||||
|
|
Loading…
Reference in New Issue