Format float type fraction Number - Android java.lang

Android examples for java.lang:Float

Description

Format float type fraction Number

Demo Code

import java.text.NumberFormat;

public class Main {

  public static String fractionNumber(float number, int maxFractionDigits) {
    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(maxFractionDigits);
    return nf.format(number);
  }//from  w  ww .  j a v a 2s  .  com

}

Related Tutorials