【Java】字符串补零
public static void main(String[] args) { int h = 5; int m = 45; int s = 2; int ms = 67; // 补零 System.out.println(String.format("%02d:%02d:%02d,%03d", h, m, s, ms)); // 05:45:02,067 }
如果忍耐算是坚强 我选择抵抗 如果妥协算是努力 我选择争取
public static void main(String[] args) { int h = 5; int m = 45; int s = 2; int ms = 67; // 补零 System.out.println(String.format("%02d:%02d:%02d,%03d", h, m, s, ms)); // 05:45:02,067 }