What is the preferred way to convert a string to a date in Java?
20151108235959 --> (15-Nov-08 11:59:59 PM)
What is the preferred way to convert a string to a date in Java?
20151108235959 --> (15-Nov-08 11:59:59 PM)
This should work as you specified in your question.
DateFormat dateFormat = new SimpleDateFormat("yy-MMM-dd HH:mm:ss a");
System.out.println(dateFormat.format(new Date()));
The date format you have in your question is something like:
DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHmmss");