DecimalFormat, Maximum Fraction Digits : Float « Date Type « Android






DecimalFormat, Maximum Fraction Digits

    

import java.text.DecimalFormat;

 class FormatUtils {
  private static final DecimalFormat formatter = new DecimalFormat();
  static {
    formatter.setDecimalSeparatorAlwaysShown(false);
    formatter.setMaximumFractionDigits(2);
  }

  public static String format(double value) {
    return formatter.format(value);
  }
}

   
    
    
    
  








Related examples in the same category

1.Convert a float to 16.16 fixed-point representation
2.Convert a 16.16 fixed-point value to floating point
3.Random and Roundup
4.Is Long or double
5.calculate NormDiff
6.Format Distance
7.Gives the fractional part of a number
8.Close to a value
9.Value equals in a range, and ensure value inside a range
10.scale, round Number
11.Returns the smallest power of two that is greater than