use of com.ibm.icu.text.DecimalFormat in project head by mifos.
the class MifosNumberFormattingInfoTag method doStartTag.
@Override
public int doStartTag() throws JspException {
try {
Locale locale = LabelTagUtils.getInstance().getUserPreferredLocale();
DecimalFormat decimalFormat = getDecimalFormat(locale);
DecimalFormatSymbols symbols = decimalFormat.getDecimalFormatSymbols();
StringBuilder sb = new StringBuilder();
sb.append("<span id=\"format.decimalSeparator\" title=\"").append(symbols.getDecimalSeparator()).append("\"></span>\n");
sb.append("<span id=\"format.groupingSeparator\" title=\"").append(symbols.getGroupingSeparator()).append("\"></span>\n");
sb.append("<span id=\"format.groupingSize\" title=\"").append(decimalFormat.getGroupingSize()).append("\"></span>\n");
pageContext.getOut().print(sb.toString());
} catch (Exception ex) {
throw new JspException("NumberFormattingInfoTag: " + ex.getMessage());
}
return SKIP_BODY;
}
use of com.ibm.icu.text.DecimalFormat in project es6draft by anba.
the class NumberFormatObject method createNumberFormat.
private NumberFormat createNumberFormat() {
ULocale locale = ULocale.forLanguageTag(this.locale);
int choice;
if ("decimal".equals(style)) {
choice = NumberFormat.NUMBERSTYLE;
} else if ("percent".equals(style)) {
choice = NumberFormat.PERCENTSTYLE;
} else {
if ("code".equals(currencyDisplay)) {
choice = NumberFormat.ISOCURRENCYSTYLE;
} else if ("symbol".equals(currencyDisplay)) {
choice = NumberFormat.CURRENCYSTYLE;
} else {
choice = NumberFormat.PLURALCURRENCYSTYLE;
}
}
DecimalFormat numberFormat = (DecimalFormat) NumberFormat.getInstance(locale, choice);
if ("currency".equals(style)) {
numberFormat.setCurrency(Currency.getInstance(currency));
}
// assert locale.getKeywordValue("numbers").equals(numberingSystem);
if (minimumSignificantDigits != 0 && maximumSignificantDigits != 0) {
numberFormat.setSignificantDigitsUsed(true);
numberFormat.setMinimumSignificantDigits(minimumSignificantDigits);
numberFormat.setMaximumSignificantDigits(maximumSignificantDigits);
} else {
numberFormat.setSignificantDigitsUsed(false);
numberFormat.setMinimumIntegerDigits(minimumIntegerDigits);
numberFormat.setMinimumFractionDigits(minimumFractionDigits);
numberFormat.setMaximumFractionDigits(maximumFractionDigits);
}
numberFormat.setGroupingUsed(useGrouping);
// as required by ToRawPrecision/ToRawFixed
// FIXME: ICU4J bug:
// new Intl.NumberFormat("en",{useGrouping:false}).format(111111111111111)
// returns "111111111111111.02"
numberFormat.setRoundingMode(BigDecimal.ROUND_HALF_UP);
return numberFormat;
}
Aggregations