method1:

前提是你的长度已经确定!比如规定现实10位! - 优点: 不需要都是数字类型
  
  String str_m =  "123X";
  String str ="0000000000";
  str_m=str.substring(0, 10-str_m.length())+str_m;
  System.out.println(str_m);

 

method2: 必须都是数字

public static void main(String[] args) {
		int i=1234;
		String str=String.format("%018d", i);
		System.out.println(str);
			
	}

  

相关文章:

  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-25
  • 2021-11-22
猜你喜欢
  • 2021-08-17
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2021-12-20
相关资源
相似解决方案