Here you can find the source of isValidDate(String s)
public static boolean isValidDate(String s)
//package com.java2s; /*//w w w. j a v a 2s. com * OpenClinica is distributed under the * GNU Lesser General Public License (GNU LGPL). * For details see: http://www.openclinica.org/license * copyright 2003-2005 Akaza Research */ import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static boolean isValidDate(String s) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd"); sdf.setLenient(false); try { java.util.Date date = sdf.parse(s); if (date.after(new java.util.Date())) { return false; // not a date in the past,for date of birth } } catch (ParseException fe) { return false; // format is wrong } return true; } }