Converting XX:XX AM/PM to 24 Hour Clock

前端 未结 6 1750
抹茶落季
抹茶落季 2021-02-15 16:41

I have searched google and I cannot find out how you can take a string: xx:xx AM/PM (ex. 3:30 PM) and change it so that it is now in 24 hours.

So for e

6条回答
  •  故里飘歌
    2021-02-15 17:24

    SimpleDateFormat inFormat = new SimpleDateFormat("hh:mm aa");
    SimpleDateFormat outFormat = new SimpleDateFormat("HH:mm");
    String time24 = outFormat.format(inFormat.parse(yourTimeString));
    

    also you can read more about converting times here http://deepeshdarshan.wordpress.com/2012/08/17/how-to-change-time-from-12-hour-format-to-24-hour-format-in-java/

提交回复
热议问题