0

I do a lof of manipulations, calculs with numbers (especialy double (#0.00) )

and I ask if is there a way to format those numbers once and for all I use this converter for the momentfor each double :

<f:convertNumber pattern="#0.00" />

thank you in advance

simonTifo
  • 307
  • 3
  • 12
  • 29

1 Answers1

0

Try this:

DecimalFormat df2 = new DecimalFormat( "#0.00" );
double d = 122.00;
System.out.println(df2.format(d));
double dou = new Double(df2.format(d)).doubleValue();
System.out.println(dou);

Output:

122.00
122.0

If you want two digits even its zero after decimal print it as String. double value of 122.00 is 12.0.If you assign double dd = 122.00 and print it will give output 122.0

Achintya Jha
  • 12,735
  • 2
  • 27
  • 39