public static DateTimeFormatter timeFormatterWithOptionalMilliseconds ( ) { // This is the .SSS part DateTimeParser ms = new DateTimeFormatterBuilder ( ) . appendLiteral ( "." ) . appendFractionOfSecond ( 1 , 3 ) . toParser ( ) ; return new DateTimeFormatterBuilder ( ) . append ( DateTimeFormat . forPattern ( ES_DATE_FORMAT_NO_MS ) . withZoneUTC ( ) ) . appendOptional ( ms ) . toFormatter ( ) ; }
Accepts our ElasticSearch time formats without milliseconds .