Here you can find the source of isTimestamp(String str, boolean allowEmpty)
public static boolean isTimestamp(String str, boolean allowEmpty)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static boolean isTimestamp(String str, boolean allowEmpty) { if (allowEmpty && isEmpty(str)) { return true; }//w w w . ja va2s .co m if (str.length() != 19 || strToDate(str) == null) { return false; } return true; } public static boolean isEmpty(String str) { return ((str == null) || (str.length() == 0)); } public static Date strToDate(String str) { if (isEmpty(str)) { return null; } SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { if (str.length() != 19) { return null; } return dateFormat.parse(str); } catch (ParseException e) { return null; } } }