java中数字转成字符串,前面自动补0

/** 
* Java里数字转字符串前面自动补0的实现。 

*/  
.public class TestStringFormat {  
  public static void main(String[] args) {  
    int youNumber = 1;  
    // 0 代表前面补充0    只能补0 不能补别的数字,否则会出现前面补空格,
    // 4 代表长度为4  
    // d 代表参数为正数型  
    String str = String.format("%04d", youNumber);  
    System.out.println(str); // 0001  
  }

系统的毫秒值 :System.currentTimeMillis() ;(13位long值)

猜你喜欢

转载自blog.csdn.net/weixin_39559282/article/details/87927453