开发者

Java equivalent of: String.format("{0:D9}", Result);

开发者 https://www.devze.com 2023-03-18 09:13 出处:网络
Does anyone know the Java equivalent of the C# format of: String.format(\"{0:D9}\", Result); Here 开发者_开发知识库what it does:http://www.java2s.com/Code/CSharp/Data-Types/doublenumberformat0C0D90

Does anyone know the Java equivalent of the C# format of:

String.format("{0:D9}", Result);

Here 开发者_开发知识库what it does: http://www.java2s.com/Code/CSharp/Data-Types/doublenumberformat0C0D90E0F30N0X0x.htm

This little problem is killin' me...


As far as I understand the documentation D9 means "format as a decimal number with at least 9 digits, left-padding with 0 if necessary).

The equivalent in Java format Strings would be %09d:

System.out.println(String.format("%09d", 1234));

This prints

000001234
0

精彩评论

暂无评论...
验证码 换一张
取 消