Getting parse exception when I'm applying a particular format to the date.
SimpleDateFormat df = new SimpleDateFormat("hh:mm a");
try {
String s=timeSlotsArrayList.get(position).getScheduledStartTime();
Date d = df.parse(s);
times.setText(df.format(d));
}
catch (ParseException e) {
e.printStackTrace();
}
AM is getting instead of PM issue image
You didn't apply correct format to your SimpleDateFormat
. Use
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
And then parse time like below:
Date d = df.parse(s);
String time = new SimpleDateFormat("hh:mm a").format(d);
times.setText(time);