I wrote the following code to get the time
public String getTime() {
final Calendar cld = Calendar.getInstance();
String time = cld.get(Calendar.HOUR) + ":" + (cld.get(Calendar.MINUTE));
try {
Date date = new SimpleDateFormat("HH:mm").parse(time);
time = new SimpleDateFormat("HH:mm").format(date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return time;
}
This always give me time like
11:59
01:07
But I need in 24 hrs format like:
11:59
13:07
How to change the code.
Use
HOUR_OF_DAYinstead ofHOUR.