Converting long (whose decimal representation represents a yyyyMMdd.. date) to a different date format
java
Solution
Here's how:
long input = 20120720162145L;
DateFormat inputDF = new SimpleDateFormat("yyyyMMddHHmmss");
DateFormat outputDF = new SimpleDateFormat("yyyy-MM-dd K:mm a");
Date date = inputDF.parse(""+input);
System.out.println(outputDF.format(date));
Output:
2012-07-20 4:21 PM
Problem
I have long of the form ``` 20120720162145 yyyymmddhhmmss ``` I have to convert it to `2012-07-20 4:21 PM` form. Is there any way in Java to do this using `Date`?