First convert your String in a date as the follow:
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateInString = "2015-07-16 17:07:21";
try {
Date date = formatter.parse(dateInString);
//And then apply the pattern
formatter.applyPattern("MM/dd/yyyy");
System.out.println(formatter.format(date));
} catch (ParseException e) {
e.printStackTrace();
}
No comments:
Post a Comment