Created
January 30, 2015 15:31
-
-
Save Goldbones/80deecc6b651134c49cf to your computer and use it in GitHub Desktop.
easiest way to see if a String like 12-03-1999 12:12:21 matches a list of dateFormats?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<SimpleDateFormat> dateFormats = new ArrayList<>(); | |
dateFormats.add(new SimpleDateFormat("dd-MM-yyyy hh:mm:ss")); | |
dateFormats.add(new SimpleDateFormat("dd/MM/yyyy hh:mm:ss")); | |
dateFormats.add(new SimpleDateFormat("dd/MM/yyyy")); | |
dateFormats.add(new SimpleDateFormat("dd-MM-yyyy")); | |
Example: | |
12-03-1999 12:12:21-> is valid | |
12-03-1999-> is valid | |
12-15-231321-> is invalid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment