Thursday, 27 February 2014

JAVA Code to convert string to date




SimpleDateFormat mydate = new SimpleDateFormat("dd-MMM-yyyy");
 String dateInString = "26-5-2013";
 
 try {
 
  Date date = mydate .parse(dateInString);
  System.out.println(date);
  System.out.println(mydate .format(date));
 
 } catch (ParseException e) {
  e.printStackTrace();
 }

No comments:

Post a Comment