Reputation: 875
I need the following number format in java:
long a=5000;
Expected output is :
50,00
if
long a = 25624;
Expected output is : 256,24
long a = 614324;
Expected output is
6143,24
How can I get this in java?
Upvotes: 1
Views: 410
Reputation: 419
Formatter class in java is used to create formatted output. To do so, the format() method is used. Syntax of format() method is as shown below:
Formatter format(String fmtString, Object ... args)
For the number format in your program the following can be done:
Formatter f = new Formatter();
f.format("%d,%2d",a/100,a%100);
Upvotes: 0