public static boolean isConsistent ( String eventDate , String startDayOfYear , String endDayOfYear , String year , String month , String day ) { if ( isEmpty ( eventDate ) || ( isEmpty ( startDayOfYear ) && isEmpty ( endDayOfYear ) && isEmpty ( year ) && isEmpty ( month ) && isEmpty ( day ) ) ) { return true ; } // TODO: Add support for eventTime boolean result = false ; result = isConsistent ( eventDate , year , month , day ) ; logger . debug ( result ) ; if ( ( result || ( ! isEmpty ( eventDate ) && isEmpty ( year ) && isEmpty ( month ) && isEmpty ( day ) ) ) && ( ! isEmpty ( startDayOfYear ) || ! isEmpty ( endDayOfYear ) ) ) { if ( endDayOfYear == null || endDayOfYear . trim ( ) . length ( ) == 0 || startDayOfYear . trim ( ) . equals ( endDayOfYear . trim ( ) ) ) { int startDayInt = - 1 ; try { startDayInt = Integer . parseInt ( startDayOfYear ) ; } catch ( NumberFormatException e ) { logger . debug ( e . getMessage ( ) ) ; logger . debug ( startDayOfYear + " is not an integer." ) ; result = false ; } if ( DateUtils . extractDate ( eventDate ) != null && DateUtils . extractDate ( eventDate ) . getDayOfYear ( ) == startDayInt ) { result = true ; } else { result = false ; } } else { int startDayInt = - 1 ; int endDayInt = - 1 ; try { startDayInt = Integer . parseInt ( startDayOfYear ) ; endDayInt = Integer . parseInt ( endDayOfYear ) ; } catch ( NumberFormatException e ) { logger . debug ( e . getMessage ( ) ) ; result = false ; } Interval eventDateInterval = DateUtils . extractDateInterval ( eventDate ) ; logger . debug ( eventDateInterval ) ; int endDayOfInterval = eventDateInterval . getEnd ( ) . getDayOfYear ( ) ; // midnight on the next day, so subtract 1 to get the same integer day. if ( eventDateInterval . getStart ( ) . getDayOfYear ( ) == startDayInt && endDayOfInterval == endDayInt ) { result = true ; } else { result = false ; } } } return result ; }
Identify whether an event date is consistent with its atomic parts .