Java Locale Format formatFraction2(final Number value)

Here you can find the source of formatFraction2(final Number value)

Description

format Fraction

License

Open Source License

Declaration

public static String formatFraction2(final Number value) 

Method Source Code

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

import java.text.NumberFormat;

import java.util.Locale;

public class Main {
    public static String formatFraction2(final Number value) {
        final Locale locale = Locale.getDefault();
        final NumberFormat format = getNumberFraction2Format(locale);
        return format.format(value);
    }//from  w w w. j  av  a  2 s  . c o  m

    public static NumberFormat getNumberFraction2Format(final Locale locale) {
        final NumberFormat format = NumberFormat.getNumberInstance(locale);
        format.setMaximumFractionDigits(2);
        format.setMinimumFractionDigits(2);
        return format;
    }
}

Related

  1. formatElapsedTime(double runTime)
  2. formatEn(T date, String pattern)
  3. formatFloat(float f, int numDecPlaces, boolean forceFractions)
  4. formatFloat(Float f, int style)
  5. formatFloat(float val)
  6. formatInCurrentDefaultLocale(double d)
  7. formatingDecimalNumber(Object obj, Locale locale, int maxIntPart, int maxFloatPart)
  8. formatInt(final int number)
  9. formatInteger(int input)