Does the style of the formatter in the parse method of the DateTime class have to match the exact style of the string? For instance, I\'m getting a TimeStamp object from the
Use LocalDateTime instead:
String input = "08-AUG-12 12.00.00 AM";
String pattern = "dd-MMM-yy hh.mm.ss aa";
LocalDateTime localDateTime = LocalDateTime.parse(input, DateTimeFormat.forPattern(pattern));
EDIT
As a matter of fact you can do it with DateTime also:
private static String parseDateTime(String input){
String pattern = "dd-MMM-yy hh.mm.ss aa";
DateTime dateTime = DateTime.parse(input, DateTimeFormat.forPattern(pattern));
return dateTime.toString("dd-MMM-yy hh:mm:ss aa");
}
Figured it out. To get the correct format, you have to call formatter.print(localDateTime object) and it worked.