Valider une date en utilisant la classe ‘DateFormat’

Author:

Valider,une,date,en,utilisant,la,classe,'DateFormat'
{filelink=5601}


import java.text.DateFormat;

public class ValiderDate
{
  public static void main(String[] arg) throws Exception
  	{
    System.out.println(estElleValide("2003-02-27"));

  }
  public static boolean estElleValide(String date) throws Exception
  {
     //Affiche une erreur si la date est incorrecte
    DateFormat fd = DateFormat.getDateInstance(DateFormat.SHORT);
    fd.setLenient(false);
    fd.parse(date);

    return true;
  }

}

A Voir sur le même Sujet:

  • SimpleDateFormat bissextile
  • simpledateformat java avec l'année bissextile

Leave a Reply

Your email address will not be published. Required fields are marked *