Java Percentage Format getPercentage(double number)

Here you can find the source of getPercentage(double number)

Description

get Percentage

License

Open Source License

Declaration

public static String getPercentage(double number) 

Method Source Code


//package com.java2s;

import java.text.NumberFormat;

public class Main {

    public static String getPercentage(double number) {
        NumberFormat nf = NumberFormat.getPercentInstance();

        nf.setMaximumFractionDigits(2);//from www . jav a  2  s.  c o m
        nf.setMinimumFractionDigits(2);

        return nf.format(number);
    }

    public static String format(double number) {
        if (number == (int) number)
            return String.valueOf((int) number);
        else
            return String.valueOf(number);
    }
}

Related

  1. formatPercentage(double percentage)
  2. formatPercentage(int enumerator, int denominator)
  3. formatTimePercent(long part, long tot)
  4. getIntRoundPercent(double f)
  5. getOneDecimalPercentFromDouble(double inValue)
  6. getPercentage(double number, int fractionDigits)
  7. getPercentage(int numerator, int denominator)
  8. getPercentage(long duration, long lapso)
  9. getPercentage(long numerator, long denominator)