主要代码如下
1 public class test { 2 3 public static void main(String[] args) { 4 long ms = 300000; 5 SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");//这里想要只保留分秒可以写成"mm:ss" 6 formatter.setTimeZone(TimeZone.getTimeZone("GMT+00:00")); 7 String hms = formatter.format(ms); 8 System.out.println(hms); 9 } 10 11 }