Here you can find the source of isYYYY(String strDate)
public static boolean isYYYY(String strDate)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public final static String YYYY = "yyyy"; public static boolean isYYYY(String strDate) { try {/* w w w . ja va 2 s . c o m*/ parse(strDate, YYYY); return true; } catch (ParseException pe) { return false; } } public static Date parse(String strDate, String pattern) throws ParseException { try { return getFormatter(pattern).parse(strDate); } catch (ParseException pe) { throw new ParseException("Method parse in Class DateUtil err: parse strDate fail.", pe.getErrorOffset()); } } private static SimpleDateFormat getFormatter(String parttern) { return new SimpleDateFormat(parttern); } }