format Percent value - Java java.lang

Java examples for java.lang:double Format

Description

format Percent value

Demo Code


//package com.java2s;

import java.text.NumberFormat;

public class Main {
    public static void main(String[] argv) throws Exception {
        double number = 2.45678;
        System.out.println(formatPercent(number));
    }/*from   ww  w.  j  av a 2s  .c o  m*/

    public static final NumberFormat PERCENT_FORMAT = NumberFormat
            .getPercentInstance();

    public static String formatPercent(double number) {
        return PERCENT_FORMAT.format(number);
    }
}

Related Tutorials