Here you can find the source of validateDatetimeString(String datetimeString, String format)
public static boolean validateDatetimeString(String datetimeString, String format)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static boolean validateDatetimeString(String datetimeString, String format) {// w w w . j av a 2 s.c o m if (datetimeString == null || datetimeString.equals("")) { return false; } SimpleDateFormat sdf = new SimpleDateFormat(format); try { sdf.parse(datetimeString); return true; } catch (ParseException e) { return false; } } }