My code is as shown below:
private String getFormattedDate(String date){
try {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
Date value = formatter.parse(date);
SimpleDateFormat dateFormatter = new SimpleDateFormat("dd-MM HH:mm a");
dateFormatter.setTimeZone(TimeZone.getDefault());
date = dateFormatter.format(value);
} catch (Exception e) {
date = "00-00-0000 00:00";
}
return date;
}
Here what I want to do is , I want to convert 2018-03-19T19:24:41.396Z
into the format 19-03 7:24 PM
, but here it gives me the output 19-03 19:24 PM
. Am I missing anything in my method because of which it is giving the false output?