Monday, December 3, 2018

java - Convert String date of format yyyy-MM-dd HH:mm:ss.SSS to String MM/dd/yyyy

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

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...