Results 1 to 5 of 5
  1. #1
    only2008 is offline Member
    Join Date
    Dec 2008
    Posts
    8
    Rep Power
    0

    Default Validate DATE format in applet

    Hi ,
    Kindly Help,
    User will enter the date in applet text field and the date has to be validated whether it is in MM/DD/YYYY format. If he has entered in wrong format then need do throw exception.
    I have chekced with SimpleDateFormat API, but no of use.

    Waiting for the reply..
    Thanks in Advance.

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    What did you try and how was it useless?

  3. #3
    only2008 is offline Member
    Join Date
    Dec 2008
    Posts
    8
    Rep Power
    0

    Default

    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    //sdf.applyPattern("MM/dd/yyyy");
    sdf.applyLocalizedPattern("MM/dd/yyyy");


    Date testDate = new Date();


    try{
    testDate = sdf.parse("29/09/2009");
    System.out.println("Date :" + sdf.parse("09/29/2009"));
    System.out.println("Date :" + sdf.format(testDate));
    }catch(Exception e){
    System.out.println("Error :" +e);
    }


    This is the source i tried which i got from other site...
    I thought there would be an exception whne we pass wrong date foramat other than which we set in format..

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Java Code:
    sdf.setLenient(false);

  5. #5
    only2008 is offline Member
    Join Date
    Dec 2008
    Posts
    8
    Rep Power
    0

Similar Threads

  1. Date Format
    By learnspring in forum New To Java
    Replies: 1
    Last Post: 11-16-2008, 05:16 PM
  2. validate time input format
    By Alairmon in forum New To Java
    Replies: 2
    Last Post: 11-04-2008, 07:39 AM
  3. how to convert date format
    By saran123 in forum New To Java
    Replies: 5
    Last Post: 10-16-2008, 06:10 PM
  4. How to validate date using SampleDateFormat
    By Java Tip in forum java.text
    Replies: 0
    Last Post: 04-04-2008, 02:38 PM
  5. How to validate date using SampleDateFormat
    By JavaBean in forum Java Tip
    Replies: 0
    Last Post: 10-04-2007, 09:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •