Java – how to print a long type value using the input size modifier?
•
Java
This is basically what I want to do
// ... some code,calculations,what have you ... long timeToAdd = returnTimeToAddInLongFormat(); // lets output the long type Now,and yes i need the width and precision. System.out.printf("Time to add: %13.10ld",timeToAdd);
I've read most of the Google searches on this topic and think I understand how to do this conceptually, but JRE will give me an unknownformatconversionexception and tell me that my input size modifier l doesn't work
Is there another way, or miss small things?
Solution
Java treats all integer values as d without LD Even bytes and BigInteger are of type D It also assumes that integers have no decimal places If you want to display 10 zeros, you can convert to double, and then use F
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码