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?
2012-07-20 4:21 PM
Date
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:
2.1m questions
2.1m answers
60 comments
57.0k users