Here you can find the source of isDateTime(String dateTime, String pattern)
public static boolean isDateTime(String dateTime, String pattern)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static boolean isDateTime(String dateTime, String pattern) { DateFormat df = new SimpleDateFormat(pattern); ParsePosition pos = new ParsePosition(0); Date dt = df.parse(dateTime, pos); return !(dt == null); }// w w w . ja va 2 s. com }