private static DateTime parseDate ( String dateStr , DateTime defaultDate , boolean floor ) { if ( "now" . equals ( dateStr ) ) { //$NON-NLS-1$ return new DateTime ( ) ; } if ( dateStr . length ( ) == 10 ) { DateTime parsed = ISODateTimeFormat . date ( ) . withZone ( DateTimeZone . UTC ) . parseDateTime ( dateStr ) ; // If what we want is the floor, then just return it. But if we want the // ceiling of the date, then we need to set the right params. if ( ! floor ) { parsed = parsed . plusDays ( 1 ) . minusMillis ( 1 ) ; } return parsed ; } if ( dateStr . length ( ) == 20 ) { return ISODateTimeFormat . dateTimeNoMillis ( ) . withZone ( DateTimeZone . UTC ) . parseDateTime ( dateStr ) ; } if ( dateStr . length ( ) == 24 ) { return ISODateTimeFormat . dateTime ( ) . withZone ( DateTimeZone . UTC ) . parseDateTime ( dateStr ) ; } return defaultDate ; }
Parses a query param representing a date into an actual date object .