I need to convert a string ( 20-04-2014) to date in the format DD-MM-YYYY of type date.
String date = "20-04-2014";
I need to convert it to a type Date. How to do this??
I need to convert a string ( 20-04-2014) to date in the format DD-MM-YYYY of type date.
String date = "20-04-2014";
I need to convert it to a type Date. How to do this??
You can use SimpleDateFormat class like this.
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
String dateString = "20-04-2014";
Date date = formatter.parse(dateString );
You can use SimpleDateFormat to implement.
Refer to http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
String date = "20-04-2014";
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
Date d = sdf.parse(date);