public static boolean isDateValid ( String date , Locale locale ) { try { DateFormat format = DateFormat . getDateTimeInstance ( DateFormat . DEFAULT , DateFormat . DEFAULT , locale ) ; format . parse ( date ) ; return true ; } catch ( ParseException e ) { return false ; } }
Because the date passed as argument can be in java format and because not all formats are compatible with joda - time this method checks if the date string is valid with java . In this way we can use the proper DateTime without changing the output .