Here you can find the source of isDateValid(String dateString, String validFormat)
public static boolean isDateValid(String dateString, String validFormat)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static boolean isDateValid(String dateString, String validFormat) { DateFormat df;//from w ww. j av a 2 s . c o m df = (validFormat == null) ? new SimpleDateFormat("yyyy-MM-dd") : new SimpleDateFormat(validFormat); df.setLenient(false); try { df.parse(dateString); return true; } catch (ParseException e) { return false; } } }