I want to format the system date time as below -
01_10_2020 08_00 AM (MM_dd_yyyy HH_mm AM/PM)
Currently I'm using the below code, but its throwing error - "error caused by: java.text.ParseException: Unparseable date: "2020-10-23T20:43:17Z"
props['currentDateTime'] = util.currentDateTimeAsString()
props['p.parsed.date'] = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm").parse(props['currentDateTime'])
props['FormattedDate'] = new java.text.SimpleDateFormat("MM_dd_yyyy HH_mm").format(props['p.parsed.date'])
props['p.filename'] = props['StuName']+' '+props['FormattedDate']
Has anyone used this date with time formatting (including AM/PM)?
Thanks,
Arnab
The value of this
props['currentDateTime']
is
"2020-10-23T20:43:17Z"
Try changing your SimpleDateFormat to match
Date j = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").parse("2020-10-23T20:43:17Z");
String k = new SimpleDateFormat("MM_dd_yyyy HH_mm").format(j);
System.out.println(k);