Here you can find the source of formatNumberSameWidth(final double v)
Parameter | Description |
---|---|
v | the number |
public static final String formatNumberSameWidth(final double v)
//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); } }