Skip to content

Instantly share code, notes, and snippets.

@akuafif
Created December 10, 2015 21:01
Show Gist options
  • Save akuafif/3e8981343c01cbfd6af8 to your computer and use it in GitHub Desktop.
Save akuafif/3e8981343c01cbfd6af8 to your computer and use it in GitHub Desktop.
[Java/Android] Date Validation from a String (eg. 32-13-2015 is not Valid)
// The Date Format
final static String DATE_FORMAT = "dd-MM-yyyy";
public static boolean isDateValid(String inputDate) {
try {
DateFormat df = new SimpleDateFormat(DATE_FORMAT);
df.setLenient(false);
df.parse(inputDate);
return true;
} catch (ParseException e) {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment