Java Locale Format formatNumberSameWidth(final double v)

Here you can find the source of formatNumberSameWidth(final double v)

Description

Format a given number for output

License

LGPL

Parameter

Parameter Description
v the number

Return

the corresponding string

Declaration

public static final String formatNumberSameWidth(final double v) 

Method Source Code

//package com.java2s;
// GNU LESSER GENERAL PUBLIC LICENSE (Version 2.1, February 1999)

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.util.Locale;

public class Main {
    /** the internal formatter */
    private static final NumberFormat FORMATTER = new DecimalFormat("0.00E00", new DecimalFormatSymbols(Locale.US));

    /**/*from  w ww  .j a  v a 2 s  .c  o  m*/
     * Format a given number for output
     *
     * @param v
     *          the number
     * @return the corresponding string
     */
    public static final String formatNumberSameWidth(final double v) {
        return FORMATTER.format(v);
    }
}

Related

  1. formatNumber(Number value, int minDecimals, int maxDecimals, boolean grouping, boolean dotDecimalSymbol)
  2. formatNumber(Number value, String format)
  3. formatNumber(Object number, String pattern, Locale locale)
  4. formatNumber(Object value, Locale locale)
  5. formatNumber(Object value, String numberFormat)
  6. formatNumberUk(double inNumber, int inDecimalPlaces)
  7. formatNumberWithThousandSeparator(long number)
  8. formatPCT(Object num)
  9. formatPersent(Object input)