Java Date Format Check checkDateFormatAndValite(String strDateTime, String format)

Here you can find the source of checkDateFormatAndValite(String strDateTime, String format)

Description

check Date Format And Valite

License

Open Source License

Declaration

public static boolean checkDateFormatAndValite(String strDateTime, String format) 

Method Source Code


//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;
        }
    }
}

Related

  1. checkDateByMask(String sDateValue, String sDateFormat)
  2. checkDateFormat()
  3. checkDateFormat()
  4. checkDateFormat(String pattern)
  5. checkDateFormat(String strTime, String pattern)
  6. checkDateInToday(Date date)
  7. checkDateRange(String fromDate, String endDate)
  8. checkDateValidity(String str, String formatString)
  9. checkTime(int id)