Here you can find the source of isValidDateStr(String date, String format)
public static boolean isValidDateStr(String date, String format)
//package com.java2s; import java.text.SimpleDateFormat; public class Main { public static boolean isValidDateStr(String date, String format) { try {/*from w w w. j a va2 s . c o m*/ if (date.length() != format.length()) { return false; } SimpleDateFormat sdf = new SimpleDateFormat(format); sdf.setLenient(false); sdf.parse(date); } catch (Exception e) { return false; } return true; } }