What is the date format to get only hours in 12-hours format from this time
Thu Oct 20 13:12:00 GMT+02:00 2011
edit:
using this code
Date eventDate = tempAppointments.get(i).mStartDate
System.out.println(eventDate.toString());
// date pattern
DateFormat df = new SimpleDateFormat("hh:'00' a");//output : Wed Nov 09 11:00:00 GMT+02:00 2011
// get the start date with new format (pattern)
String hours = df.format(tempAppointments.get(i).mStartDate.getDay());
System.out.print(hours);//output: 02:00 AM
return hours as
02:00 AM
but for the given time. it must be 02:00 PM . why ?
I’m not sure why you are passing
date.getDay()(which is deprecated, by the way) into the formatter if you want the hour part.Try this:-
The output: