0

I am working on some application where I need to parse logger stack trace date into required format kindly help me on this..

Date format after parsing logger : [Wed Jul 22 09:29:09 2015] Required format : yyyy-MM-dd HH:mm:ss

Kiran
  • 921
  • 1
  • 11
  • 23
  • possible duplicate of [How to parse dates in multiple formats using SimpleDateFormat](http://stackoverflow.com/questions/4024544/how-to-parse-dates-in-multiple-formats-using-simpledateformat) – Armfoot Sep 29 '15 at 11:04

1 Answers1

0
SimpleDateFormat loggerFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy");
SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

Date date = loggerFormat.parse("Wed Jul 22 09:29:09 2015");
String output = targetFormat.format(date); // 2015-07-22 09:29:09
Bohuslav Burghardt
  • 33,626
  • 7
  • 114
  • 109