-5

What is the preferred way to convert a string to a date in Java?

20151108235959 --> (15-Nov-08 11:59:59 PM)
4444
  • 3,541
  • 10
  • 32
  • 43

1 Answers1

1

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");
intboolstring
  • 6,891
  • 5
  • 30
  • 44