Java Date Value Check isValidDate(DateFormat sdf, String date)

Here you can find the source of isValidDate(DateFormat sdf, String date)

Description

is Valid Date

License

Open Source License

Declaration

public static boolean isValidDate(DateFormat sdf, String date) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 Robert "Unlogic" Olofsson (unlogic@unlogic.se).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v3
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl-3.0-standalone.html
 ******************************************************************************/

import java.text.DateFormat;
import java.text.ParseException;

public class Main {
    public static boolean isValidDate(DateFormat sdf, String date) {

        try {//from w ww.ja  v  a  2s . c o m
            sdf.parse(date);
        } catch (ParseException e) {
            return false;
        } catch (RuntimeException e) {
            return false;
        }
        return true;
    }
}

Related

  1. isDateValid(String dateString, String validFormat)
  2. isDateValid(String dateToCheck, String pattern)
  3. isDateValid(String dateToValidate)
  4. isDateValue(String inputString)
  5. isValidateData(String val)
  6. isValidDate(final String date, final String format, final boolean lenient)
  7. isValidDate(final String date, final String format, final Locale locale)
  8. isValidDate(String createDate, String startDate)
  9. isValidDate(String date)