Java Date Value Check IsDateOK(String date)

Here you can find the source of IsDateOK(String date)

Description

Returns true if the date is in format year/month/day, false if not

License

Open Source License

Parameter

Parameter Description
date a parameter

Declaration

public static boolean IsDateOK(String date) 

Method Source Code

//package com.java2s;
/*Copyright 2008 by Vladimir Polony, Stupy 24, Banska Bystrica, Slovakia
    /*from  www .  ja v a2  s.c  om*/
This file is part of OpenRep FREE homeopathic software.
    
OpenRep FREE is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
    
OpenRep FREE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with OpenRep FREE.  If not, see <http://www.gnu.org/licenses/>.*/

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /** Returns true if the date is in format year/month/day, false if not
     * 
     * @param date
     * @return
     */
    public static boolean IsDateOK(String date) {
        try {
            DateFormat fmt = new SimpleDateFormat("yyyy/MM/dd");
            Date d = fmt.parse(date);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}

Related

  1. isDateFormat(String str, String format)
  2. isDateFormatString(String s, String dateFormat, Locale locale)
  3. isDateFormatValid(final String pattern)
  4. isDateInRange(Date startDt, Date endDt, Date theDate)
  5. isDateInRange(Date toCheck, Date minRange, Date maxRange)
  6. isDateSortedAsc(List dates, String format)
  7. isDateTwo(String value)
  8. isDateValid(String date, Locale locale)
  9. isDateValid(String dateString, String validFormat)