Here you can find the source of isValidDateFormat(String strDate, String dataFormat)
public static boolean isValidDateFormat(String strDate, String dataFormat)
//package com.java2s; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static boolean isValidDateFormat(String strDate, String dataFormat) {/*from w w w.j a v a 2 s . c o m*/ DateFormat df = getNewDateFormat(dataFormat); try { df.parse(strDate); } catch (ParseException e) { return false; } return true; } public static DateFormat getNewDateFormat(String pattern) { DateFormat df = new SimpleDateFormat(pattern); df.setLenient(false); return df; } }