Example usage for java.text DecimalFormat getInstance

List of usage examples for java.text DecimalFormat getInstance

Introduction

In this page you can find the example usage for java.text DecimalFormat getInstance.

Prototype

public static final NumberFormat getInstance() 

Source Link

Document

Returns a general-purpose number format for the current default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

From source file:fr.paris.lutece.portal.web.upload.UploadFilter.java

/**
 *
 * @return the size of the request to display in the error message
 *///from   w  w  w  .ja va 2  s  . c  o  m
private String getDisplaySize() {
    long lSizeMax = getRequestSizeMax();
    DecimalFormat decimalFormat = (DecimalFormat) DecimalFormat.getInstance();
    decimalFormat.applyPattern("#");

    String strMessage = (lSizeMax >= KILO_BYTE) ? (String.valueOf(lSizeMax / KILO_BYTE))
            : (decimalFormat.format(lSizeMax / KILO_BYTE));

    return strMessage;
}

From source file:org.libreplan.web.common.Util.java

/**
 * Returns the value using the money format, that means, 2 figures for the
 * decimal part and concatenating the currency symbol from {@link Configuration} object.
 *//*from   w  ww.j ava2s  .  c om*/
public static String addCurrencySymbol(BigDecimal value) {
    BigDecimal valueToReturn = value == null ? BigDecimal.ZERO : value;
    DecimalFormat decimalFormat = (DecimalFormat) DecimalFormat.getInstance();
    decimalFormat.applyPattern(getMoneyFormat());

    return decimalFormat.format(valueToReturn);
}