Java Locale Format formatNumberUk(double inNumber, int inDecimalPlaces)

Here you can find the source of formatNumberUk(double inNumber, int inDecimalPlaces)

Description

Format the given number in UK format (decimal point) to the given number of decimal places

License

Open Source License

Parameter

Parameter Description
inNumber double number to format
inDecimalPlaces number of decimal places

Declaration

public static String formatNumberUk(double inNumber, int inDecimalPlaces) 

Method Source Code

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

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

public class Main {
    /** UK-specific number formatter object to avoid lots of instantiations */
    private static final NumberFormat UK_FORMAT = NumberFormat.getNumberInstance(Locale.UK);

    /**//from  www .j  ava2s .  c o m
     * Format the given number in UK format (decimal point) to the given number of decimal places
     * @param inNumber double number to format
     * @param inDecimalPlaces number of decimal places
     */
    public static String formatNumberUk(double inNumber, int inDecimalPlaces) {
        UK_FORMAT.setMaximumFractionDigits(inDecimalPlaces);
        UK_FORMAT.setMinimumFractionDigits(inDecimalPlaces);
        return UK_FORMAT.format(inNumber);
    }
}

Related

  1. formatNumber(Number value, String format)
  2. formatNumber(Object number, String pattern, Locale locale)
  3. formatNumber(Object value, Locale locale)
  4. formatNumber(Object value, String numberFormat)
  5. formatNumberSameWidth(final double v)
  6. formatNumberWithThousandSeparator(long number)
  7. formatPCT(Object num)
  8. formatPersent(Object input)
  9. formatSmartDate(Date date)