Results 1 to 5 of 5
Thread: Validate DATE format in applet
- 09-29-2009, 08:37 AM #1
Member
- Join Date
- Dec 2008
- Posts
- 8
- Rep Power
- 0
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.
- 09-29-2009, 08:52 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
What did you try and how was it useless?
- 09-29-2009, 08:59 AM #3
Member
- Join Date
- Dec 2008
- Posts
- 8
- Rep Power
- 0
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..
- 09-29-2009, 09:07 AM #4
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Java Code:sdf.setLenient(false);
- 09-29-2009, 09:20 AM #5
Member
- Join Date
- Dec 2008
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
Date Format
By learnspring in forum New To JavaReplies: 1Last Post: 11-16-2008, 05:16 PM -
validate time input format
By Alairmon in forum New To JavaReplies: 2Last Post: 11-04-2008, 07:39 AM -
how to convert date format
By saran123 in forum New To JavaReplies: 5Last Post: 10-16-2008, 06:10 PM -
How to validate date using SampleDateFormat
By Java Tip in forum java.textReplies: 0Last Post: 04-04-2008, 02:38 PM -
How to validate date using SampleDateFormat
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:31 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks