Java Date Format Check checkDateValidity(String str, String formatString)

Here you can find the source of checkDateValidity(String str, String formatString)

Description

check Date Validity

License

Open Source License

Declaration

public static boolean checkDateValidity(String str, String formatString) 

Method Source Code


//package com.java2s;

import java.text.ParseException;
import java.text.SimpleDateFormat;

public class Main {

    public static boolean checkDateValidity(String str, String formatString) {
        SimpleDateFormat sdf = new SimpleDateFormat(formatString);
        sdf.setLenient(false);//from ww w  .  j av  a  2 s . c o m
        try {
            sdf.parse(str);
            return true;
        } catch (ParseException e) {
            return false;
        }
    }
}

Related

  1. checkDateFormat(String pattern)
  2. checkDateFormat(String strTime, String pattern)
  3. checkDateFormatAndValite(String strDateTime, String format)
  4. checkDateInToday(Date date)
  5. checkDateRange(String fromDate, String endDate)
  6. checkTime(int id)
  7. checkTimestamp(String timestamp)