Here you can find the source of checkDateFormatAndValite(String strDateTime, String format)
public static boolean checkDateFormatAndValite(String strDateTime, String format)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static boolean checkDateFormatAndValite(String strDateTime, String format) { if (strDateTime == null || strDateTime.length() == 0) { return false; }/*from www . j a v a2 s .c o m*/ SimpleDateFormat sdf = new SimpleDateFormat(format); try { Date ndate = sdf.parse(strDateTime); String str = sdf.format(ndate); System.out.println("func<checkDateFormatAndValite> strDateTime<" + strDateTime + "> format<" + format + "> str<" + str + ">"); if (str.equals(strDateTime)) { return true; } else { return false; } } catch (Exception e) { e.printStackTrace(); return false; } } }