Here you can find the source of isValidPattern(String dateString, String pattern)
public static Boolean isValidPattern(String dateString, String pattern)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Boolean isValidPattern(String dateString, String pattern) { return parse(dateString, pattern) != null; }//from w w w . ja v a 2 s. c om public static Date parse(String dateString, String pattern) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); try { return simpleDateFormat.parse(dateString); } catch (ParseException e) { } return null; } }