@@ -26,10 +26,14 @@ public class Analyzers {
2626 .appendOptional (DateTimeFormatter .ISO_LOCAL_DATE_TIME ) // e.g. 2010-12-30T00:00:00
2727 .appendOptional (DateTimeFormatter .ISO_LOCAL_DATE ) // e.g. 2010-12-30
2828 .appendOptional (new DateTimeFormatterBuilder ()
29- .appendValue (ChronoField .YEAR )
30- .appendPattern ("-MM-dd" ).toFormatter ()) // e.g. -200-01-01
31- .appendOptional (new DateTimeFormatterBuilder ()
32- .appendValue (ChronoField .YEAR ).toFormatter ()) // e.g. -200
29+ .appendValue (ChronoField .YEAR ) // e.g. -200
30+ .optionalStart ()
31+ .appendPattern ("-MM" ) // e.g. -200-10
32+ .optionalEnd ()
33+ .optionalStart ()
34+ .appendPattern ("-dd" ) // e.g. -200-01-01
35+ .optionalEnd ()
36+ .toFormatter ())
3337 .toFormatter ()
3438 .withResolverStyle (ResolverStyle .STRICT );
3539
@@ -256,6 +260,7 @@ private static TemporalAccessor parseDate(String date) {
256260 ZonedDateTime ::from ,
257261 LocalDateTime ::from ,
258262 LocalDate ::from ,
263+ YearMonth ::from ,
259264 Year ::from );
260265 } catch (Exception e ) {
261266 return null ;
@@ -298,13 +303,19 @@ static String utcDateTimeString(TemporalAccessor parsedDate, boolean start) {
298303 if (parsedDate instanceof Year ) {
299304 LocalDateTime yearDate = start ?
300305 ((Year ) parsedDate ).atMonth (1 ).atDay (1 ).atStartOfDay () :
301- ((Year ) parsedDate ).atMonth (12 ).atEndOfMonth ().atTime (23 , 59 , 59 );
306+ ((Year ) parsedDate ).atMonth (12 ).atEndOfMonth ().atTime (23 , 59 , 59 , 999000000 );
302307 return DateTimeFormatter .ISO_ZONED_DATE_TIME .format (yearDate .atZone (ZoneOffset .UTC ));
303308 }
309+ if (parsedDate instanceof YearMonth ) {
310+ LocalDateTime yearMonthDate = start ?
311+ ((YearMonth ) parsedDate ).atDay (1 ).atStartOfDay () :
312+ ((YearMonth ) parsedDate ).atEndOfMonth ().atTime (23 , 59 , 59 , 999000000 );
313+ return DateTimeFormatter .ISO_ZONED_DATE_TIME .format ((yearMonthDate .atZone (ZoneOffset .UTC )));
314+ }
304315 if (parsedDate instanceof LocalDate ) {
305316 LocalDateTime localDate = start ?
306317 ((LocalDate ) parsedDate ).atStartOfDay () :
307- ((LocalDate ) parsedDate ).atTime (23 , 59 , 59 );
318+ ((LocalDate ) parsedDate ).atTime (23 , 59 , 59 , 999000000 );
308319 return DateTimeFormatter .ISO_ZONED_DATE_TIME .format (localDate .atZone (ZoneOffset .UTC ));
309320 }
310321 if (parsedDate instanceof LocalDateTime ) {
@@ -318,7 +329,7 @@ static String utcDateTimeString(TemporalAccessor parsedDate, boolean start) {
318329 }
319330
320331 static String utcDateTimeString (Long year , boolean start ) {
321- return start ? year .toString () + "-01-01T00:00:00Z" : year .toString () + "-12-31T23:59:59Z " ;
332+ return start ? year .toString () + "-01-01T00:00:00Z" : year .toString () + "-12-31T23:59:59.999Z " ;
322333 }
323334
324335 static TimeRangeDescriptor rangeDescriptor (DateInfo beginInfo , DateInfo endInfo , DateInfo instantInfo ) {
0 commit comments