U got date input as string. (In some MM/DD/YYYY format)
Now I want the equivalent Java date object.
(For further validity & further processing.)
Use the following segment.
public static void main(String args[])
{
String dt = "10-10-1990"; // some test data
try{
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy");
// input date format
format.setLenient(false);
Date date = format.parse( dt );
System.out.println("The parsed date: " + date);
} catch (ParseException e) {
System.out.println(e.getMessage());
}
No comments:
Post a Comment