Here you can find the source of isValidLongDateFormat(String strDate)
public static boolean isValidLongDateFormat(String strDate)
//package com.java2s; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public final static String longFormat = "yyyyMMddHHmmss"; public static boolean isValidLongDateFormat(String strDate) { if (strDate.length() != longFormat.length()) { return false; }//from w w w . j ava2s . co m DateFormat df = createNewDateFormat(longFormat); try { df.parse(strDate); } catch (ParseException e) { return false; } return true; } public static boolean isValidLongDateFormat(String strDate, String delimiter) { String temp = strDate.replaceAll(delimiter, ""); return isValidLongDateFormat(temp); } public static DateFormat createNewDateFormat(String pattern) { DateFormat df = new SimpleDateFormat(pattern); df.setLenient(false); return df; } }