Here you can find the source of isDate(String str, String pattern)
public static boolean isDate(String str, String pattern)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; public class Main { public static boolean isDate(String str, String pattern) { if (str == null) { return false; }//w w w . j ava 2 s . co m if (pattern == null) { pattern = "YYYYMMDD"; } SimpleDateFormat sdf = new SimpleDateFormat(pattern); try { sdf.parse(str); } catch (Exception e) { return false; } return true; } }