I have a DecimalFormat in java and when I use it, it does not work as expected.
In the input I'm getting 150000, and I want to have the 15.00 as an outcome.
The code looks as follows:
import java.text.DecimalFormat;
public class MyClass {
public static void main(String args[]) {
long x=150000;
DecimalFormat df = new DecimalFormat("#.##");
System.out.println("x " + x/10000);
long y = x/10000;
System.out.println(df.format(y));
}
}
and still, the console shows 15 instead of 15.00. What am I missing here?
Btw, is there any better way to make such formatter (while trying to convert 15000 to 15.00)? Or is the best option to just divide it by 10000 in that case? Thank you for any feedback!