Java Percentage Format getOneDecimalPercentFromDouble(double inValue)

Here you can find the source of getOneDecimalPercentFromDouble(double inValue)

Description

Return a percent value with 1 decimal value and the % at the end: 98.7% used everywhere for example to show quality and reference evaluation values in the table

License

Open Source License

Parameter

Parameter Description
inValue a double value between 0 & 1

Declaration

public static String getOneDecimalPercentFromDouble(double inValue) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;

import java.util.Locale;

public class Main {
    /**/*from w w  w  .j a v  a2  s .  co  m*/
     * Return a percent value with 1 decimal value and the % at the end: 98.7% 
     * used everywhere for example to show quality and reference evaluation values in the table
     * @param inValue a double value between 0 & 1
     * @return
     */
    public static String getOneDecimalPercentFromDouble(double inValue) {
        String shortString = "";
        if (!(new Double(inValue)).isNaN()) {
            double d = inValue * 100;
            DecimalFormat oneDec = new DecimalFormat("0.0", new DecimalFormatSymbols(Locale.US));
            shortString = (oneDec.format(d));
            shortString += "%";
        } else
            shortString = "0.0%";
        return shortString;

    }
}

Related

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