private int compareTimeOfDates ( final Date d1 , final Date d2 ) { final LocalTime lt1 = LocalDateTime . ofInstant ( d1 . toInstant ( ) , ZONEID_UTC ) . toLocalTime ( ) ; final LocalTime lt2 = LocalDateTime . ofInstant ( d2 . toInstant ( ) , ZONEID_UTC ) . toLocalTime ( ) ; return lt1 . compareTo ( lt2 ) ; }
Because parsing done by base class returns a different date than parsing done by the user or converting duration to a date . But for the DurationField comparison only the time is important . This function helps comparing the time and ignores the values for day month and year .