i have a simple method to convert dates
private static SimpleDateFormat uiSDF = new SimpleDateFormat("MMM dd, yyyy hh:mm a");
try {
System.out.println("DATE1 " + date);
String abc1 = uiSDF.format(date);
System.out.println("DATE2 " + abc1);
Date abc2 = uiSDF.parse(abc1);
System.out.println("DATE3 " + abc2);
return uiSDF.parse(uiSDF.format(date));
} catch (ParseException e) {
System.out.println(DateConverter.class.getName() + " convertDBTimeStampToUIDate :" + e);
e.printStackTrace();
return null;
}
convert the date to a string with a new format and convert that string into a date. issue is the .parse returns back the format to its original.
DATE1 Fri Oct 09 21:11:40 SGT 2020
DATE2 Oct 09, 2020 09:11 PM
DATE3 Fri Oct 09 21:11:00 SGT 2020
DATE3 sysout should be same as DATE2 since i used the same uiSDF simpledateformat. Any idea why is reverting back to original date format?