Format double value with #####0.00 in Java
Description
The following code shows how to format double value with #####0.00.
Example
//from ww w .ja v a 2 s.c o m
import java.text.DecimalFormat;
public class Main {
public static void main(String args[]) {
double d = 123456.7890;
DecimalFormat df = new DecimalFormat("#####0.00");
System.out.println(df.format(d));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »