Here you can find the source of isDate(String str, String format)
public static boolean isDate(String str, String format)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; public class Main { public static boolean isDate(String str, String format) { if (hasLength(str)) { SimpleDateFormat formatter = new SimpleDateFormat(format); formatter.setLenient(false); try { formatter.format(formatter.parse(str)); } catch (Exception e) { return false; }/*from ww w . j av a 2 s .c o m*/ return true; } return false; } public static boolean hasLength(String str) { return str != null && str.trim().length() > 0; } }