Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; public class Main { public static boolean checkDate(String str) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); try { formatter.parse(str); return true; } catch (Exception e) { return false; } } public static boolean checkDate(String str, String format) { SimpleDateFormat formatter = new SimpleDateFormat(format); try { formatter.parse(str); return true; } catch (Exception e) { return false; } } }