I'm reading and writing a file, but I need the output to be formatted to 2 decimal places? How do you do "writer.write" with a double and format it?
Asked
Active
Viewed 40 times
1 Answers
0
System.out.printf("%.02f", 0.1234);
Output:
0.12
System.out.printf("%.02f", 0.1);
Ouput:
0.10
OR:
new DecimalFormat("#.##").format(1.199);
Results in:
1.2
Olian04
- 5,841
- 2
- 29
- 49