February 2017
Beginner
1056 pages
28h 57m
English
DecimalFormat Decimal_Format_Object_Name= DecimalFormat(Pattern);
DecimalFormat formattingObject = new DecimalFormat("00.000");
You then can use the method format to convert a value of type double to a corresponding numeral String, as follows:
Decimal_Format_Object_Name.format(Double_Expression)
The method returns a string that corresponds to Double_Expression.
System.out.println(formattingObject.format(12.3456));
If the object formattingObject is created with the pattern "00.000", as in our previous example, the output produced by the foregoing println statement is 12.346.
Note that the method format returns a string that is an object of the class StringBuffer, not String. StringBuffer is similar to String ...
Read now
Unlock full access