Here you can find the source of isValidDate(String dateStr)
public static boolean isValidDate(String dateStr)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; public class Main { public static boolean isValidDate(String dateStr) { boolean isValid = false; if (dateStr == null || dateStr.length() <= 0) { return false; }//from w ww . j a v a 2 s . c om String pattern = "yyyy-MM-dd"; try { SimpleDateFormat sdf = new SimpleDateFormat(pattern); String date = sdf.format(sdf.parse(dateStr)); if (date.equalsIgnoreCase(dateStr)) { isValid = true; } } catch (Exception e) { isValid = false; } return isValid; } }