Java Date Value Check isValidDate(String dt)

Here you can find the source of isValidDate(String dt)

Description

is Valid Date

License

Open Source License

Declaration

public static boolean isValidDate(String dt) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static boolean isValidDate(String dt) {
        //__Prepare result
        Boolean result = true;//from  w  w w.j  a  v a  2 s .c om

        String dateformat = "yyyyMMdd";

        try {
            SimpleDateFormat sdf = new SimpleDateFormat(dateformat);
            sdf.setLenient(false);
            sdf.parse(dt);
        } catch (ParseException e) {
            result = false;
        } catch (IllegalArgumentException e) {
            result = false;
        }

        return result;
    }
}

Related

  1. isValidDate(String dateString, String dateFormat)
  2. isValidDate(String dateString, String dateFormat)
  3. isValidDate(String dateString, String dateFormat)
  4. isValidDate(String dateString, String dateFormatPattern)
  5. isValidDate(String dateString, String format)
  6. isValidDate(String inDate)
  7. isValidDate(String psDt)
  8. isValidDate(String s)
  9. isValidDate(String src, String format)