Java format hour and min

后端 未结 4 1320
梦毁少年i
梦毁少年i 2020-12-11 09:36

I need to format my time string such as this:

int time = 160;

Here\'s my sample code:

public static String formatDuration(         


        
4条回答
  •  青春惊慌失措
    2020-12-11 10:14

    Just try

    sdf = new SimpleDateFormat("HH 'hrs' mm 'mins'");
    

    There is a good documentation https://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html From the doc:

    "Text can be quoted using single quotes (') to avoid interpretation."

提交回复
热议问题