@ Nullable public static OffsetDateTime parseOffsetDateTimeUsingMask ( @ Nonnull final PDTMask < ? > [ ] aMasks , @ Nonnull @ Nonempty final String sDate ) { for ( final PDTMask < ? > aMask : aMasks ) { final DateTimeFormatter aDTF = PDTFormatter . getForPattern ( aMask . getPattern ( ) , LOCALE_TO_USE ) ; try { final Temporal ret = aDTF . parse ( sDate , aMask . getQuery ( ) ) ; if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Parsed '" + sDate + "' with '" + aMask . getPattern ( ) + "' to " + ret . getClass ( ) . getName ( ) ) ; return TypeConverter . convert ( ret , OffsetDateTime . class ) ; } catch ( final DateTimeParseException ex ) { if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Failed to parse '" + sDate + "' with '" + aMask . getPattern ( ) + "': " + ex . getMessage ( ) ) ; } } return null ; }
Parses a Date out of a string using an array of masks . It uses the masks in order until one of them succeeds or all fail .