Reputation: 1
I'm trying to format the number 0.14000
using java.text.DecimalFormat
in order to obtain the value 0.14
. Using the format #.##
I get 140
. What's wrong?
Upvotes: 0
Views: 1114
Reputation: 684
Please try
DecimalFormat decimalFormat = new DecimalFormat("0.00");
Example:
import java.text.DecimalFormat;
public class MyDecimalFormat {
public static void main(String[] args) {
DecimalFormat decimalFormat = new DecimalFormat("0.00");
System.out.println( decimalFormat.format( 0.14000 ) );
}
}
Output:
0.14
Upvotes: 1