Getting the current time and date on a 24 hour timescale

前端 未结 3 741

I am having problems getting the current time on a 24 hour timescale. As far as I know, \"HH\" should represent the current hour on a 24 hour timescale, however, for some re

3条回答
  •  無奈伤痛
    2020-12-10 14:17

    You can use SimpleDateFormat to format it the way you like, this works:

    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
    String str = sdf.format(new Date());
    

    Also Android version of docs.

提交回复
热议问题