Java Percentage Format toPercent(Double doubleValue)

Here you can find the source of toPercent(Double doubleValue)

Description

Format in percent value

License

Open Source License

Parameter

Parameter Description
doubleValue a parameter

Declaration

public static String toPercent(Double doubleValue) 

Method Source Code


//package com.java2s;
/*/*  ww  w .ja v a 2s  .co  m*/
 * Copyright (C) 2009-2015 SM2 SOFTWARE & SERVICES MANAGEMENT
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program has been created in the hope that it will be useful.
 * It is distributed WITHOUT ANY WARRANTY of any Kind,
 * without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 *
 * For more information, please contact SM2 Software & Services Management.
 * Mail: info@talaia-openppm.com
 * Web: http://www.talaia-openppm.com
 *
 * Module: utils
 * File: ValidateUtil.java
 * Create User: javier.hernandez
 * Create Date: 06/03/2015 14:35:37
 */

import java.text.DecimalFormat;

public class Main {
    /**
     * Format in percent value
     * @param doubleValue
     * @return
     */
    public static String toPercent(Double doubleValue) {

        DecimalFormat df = new DecimalFormat("###.##%");
        df.setMaximumFractionDigits(2);
        df.setMinimumFractionDigits(2);

        String formatDouble = "";

        if (doubleValue != null) {
            formatDouble = df.format(doubleValue);
        }
        return formatDouble;
    }
}

Related

  1. percentFormat(final double value)
  2. percentFormat(float value)
  3. percentFormat(Object object)
  4. percentTotal(double value, double total)
  5. roundedPercentageGreaterThan(double left, double right)
  6. toPercent(double percent)
  7. toPercent(double value)
  8. toPercent(float f)