how to validate date and time format in java i want validate this date formate YYYY-MM-DDThh:mm:ss
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Wednesday, September 26, 2007 02:07 AM

how to validate date and time format in java i want validate this date formate YYYY-MM-DDThh:mm:ss i have the code to validate YYYY-MM-DD but i want validate this formate YYYY-MM-DDThh:mm:ss please help me on this issue. here is the code to validate YYYY-MM-DD format private boolean validateDateFormate(String date) { try { String dateFormat="yyyy-MM-dd"; String temp = date.substring(0,date.indexOf("-")); if(temp.length()!= 4) return false; SimpleDateFormat df=new SimpleDateFormat(dateFormat); Date date1=df.parse(date); String resultDateString=df.   More>>

how to validate date and time format in java

i want validate this date formate YYYY-MM-DDThh:mm:ss

i have the code to validate YYYY-MM-DD but i want validate
this formate YYYY-MM-DDThh:mm:ss

please help me on this issue.

here is the code to validate YYYY-MM-DD format

private boolean validateDateFormate(String date)

{

try

{

String dateFormat="yyyy-MM-dd";

String temp = date.substring(0,date.indexOf("-"));

if(temp.length()!= 4)

return false;

SimpleDateFormat df=new SimpleDateFormat(dateFormat);

Date date1=df.parse(date);

String resultDateString=df.format(date1);

if ( !date.equals(resultDateString))
return false;

}

catch (Exception de)

{
return false;
}

return true;

}

   <<Less

Re: how to validate date and time format in java

Posted By:   Christopher_Koenigsberg  
Posted On:   Monday, October 8, 2007 08:04 PM

I'm not familiar with all the different kinds of date/time formats, but don't you just supply your template string to the SimpleDateFormat constructor?



I don't know what your "T" is supposed to mean, between your DD days and your hh hours? maybe that's the problem? sorry if it's obvious.
About | Sitemap | Contact