Use SimpleDateFormat, but note that HH is different from hh.
Say we have time 18:20
The format below will return 18:20
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm aa");
Until this format returns 6:20 pm
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm aa");
Hope this helps ...
source share