I have following line of code:
DecimalFormat df = new DecimalFormat("#.##");
System.out.println(df.format(23.00));
System.out.println(Double.parseDouble(df.format(23.00d)));
System.out.println(df.parse("23.00").doubleValue());
First line print 23
but in 2nd and 3rd line when i convert it to double it prints 23.0
. showing 23.0
doesnt makes any sense.
How can i get a double
value 23
.
I checked these best-way-to-format-a-double-value-to-2-decimal-places how-to-nicely-format-floating-numbers-to-string-without-unnecessary-decimal-0