private String addNegativeSign(String unsignedNumeral) { String negativePrefix = ""; String negativeSuffix = ""; if (!decimalFormat.getNegativePrefix().isEmpty()) { negativePrefix = "\\Q" + decimalFormat.getNegativePrefix() + "\\E"; } if (!decimalFormat.getNegativeSuffix().isEmpty()) { negativeSuffix = "\\Q" + decimalFormat.getNegativeSuffix() + "\\E"; } return negativePrefix + unsignedNumeral + negativeSuffix; }
String positiveSuffix = decimalFormat.getPositiveSuffix(); String negativePrefix = decimalFormat.getNegativePrefix(); String negativeSuffix = decimalFormat.getNegativeSuffix();
/** * Returns the negative suffix. * * <p>Examples: -123%, ($123) (with positive suffixes) * * @return the suffix * @stable ICU 2.0 */ public String getNegativeSuffix() { return ((java.text.DecimalFormat)numberFormat).getNegativeSuffix(); }
/** * Returns the negative suffix. * * <p>Examples: -123%, ($123) (with positive suffixes) * * @return the suffix * @stable ICU 2.0 */ public String getNegativeSuffix() { return ((java.text.DecimalFormat)numberFormat).getNegativeSuffix(); }
private String addNegativeSign(String unsignedNumeral) { String negativePrefix = ""; String negativeSuffix = ""; if (!decimalFormat.getNegativePrefix().isEmpty()) { negativePrefix = "\\Q" + decimalFormat.getNegativePrefix() + "\\E"; } if (!decimalFormat.getNegativeSuffix().isEmpty()) { negativeSuffix = "\\Q" + decimalFormat.getNegativeSuffix() + "\\E"; } return negativePrefix + unsignedNumeral + negativeSuffix; }
private String addNegativeSign(String unsignedNumeral) { String negativePrefix = ""; String negativeSuffix = ""; if (!decimalFormat.getNegativePrefix().isEmpty()) { negativePrefix = "\\Q" + decimalFormat.getNegativePrefix() + "\\E"; } if (!decimalFormat.getNegativeSuffix().isEmpty()) { negativeSuffix = "\\Q" + decimalFormat.getNegativeSuffix() + "\\E"; } return negativePrefix + unsignedNumeral + negativeSuffix; }
private String addNegativeSign(String unsignedNumeral) { String negativePrefix = ""; String negativeSuffix = ""; if (!decimalFormat.getNegativePrefix().isEmpty()) { negativePrefix = "\\Q" + decimalFormat.getNegativePrefix() + "\\E"; } if (!decimalFormat.getNegativeSuffix().isEmpty()) { negativeSuffix = "\\Q" + decimalFormat.getNegativeSuffix() + "\\E"; } return negativePrefix + unsignedNumeral + negativeSuffix; }
private String addNegativeSign(String unsignedNumeral) { String negativePrefix = ""; String negativeSuffix = ""; if (!decimalFormat.getNegativePrefix().isEmpty()) { negativePrefix = "\\Q" + decimalFormat.getNegativePrefix() + "\\E"; } if (!decimalFormat.getNegativeSuffix().isEmpty()) { negativeSuffix = "\\Q" + decimalFormat.getNegativeSuffix() + "\\E"; } return negativePrefix + unsignedNumeral + negativeSuffix; }
private String addNegativeSign(String unsignedNumeral) { String negativePrefix = ""; String negativeSuffix = ""; if (!decimalFormat.getNegativePrefix().isEmpty()) { negativePrefix = "\\Q" + decimalFormat.getNegativePrefix() + "\\E"; } if (!decimalFormat.getNegativeSuffix().isEmpty()) { negativeSuffix = "\\Q" + decimalFormat.getNegativeSuffix() + "\\E"; } return negativePrefix + unsignedNumeral + negativeSuffix; }
private String addNegativeSign(String unsignedNumeral) { String negativePrefix = ""; String negativeSuffix = ""; if (!decimalFormat.getNegativePrefix().isEmpty()) { negativePrefix = "\\Q" + decimalFormat.getNegativePrefix() + "\\E"; } if (!decimalFormat.getNegativeSuffix().isEmpty()) { negativeSuffix = "\\Q" + decimalFormat.getNegativeSuffix() + "\\E"; } return negativePrefix + unsignedNumeral + negativeSuffix; }
private String addNegativeSign(String unsignedNumeral) { String negativePrefix = ""; String negativeSuffix = ""; if (!decimalFormat.getNegativePrefix().isEmpty()) { negativePrefix = "\\Q" + decimalFormat.getNegativePrefix() + "\\E"; } if (!decimalFormat.getNegativeSuffix().isEmpty()) { negativeSuffix = "\\Q" + decimalFormat.getNegativeSuffix() + "\\E"; } return negativePrefix + unsignedNumeral + negativeSuffix; }
String LocaleCountry = new Locale("en").getDefault().getCountry(); String LocaleLanguage = new Locale("en").getDefault().getLanguage(); String LocaleCurrency = new DecimalFormatSymbols().getCurrency().toString(); String LocaleShortDateTimePattern =new SimpleDateFormat().toPattern(); char LocaleDecimalSeparator = new DecimalFormatSymbols().getDecimalSeparator(); char LocaleThousandSeparator = new DecimalFormatSymbols().getGroupingSeparator(); String LocaleThousandGrouping = String.format("%d;0", new DecimalFormat().getMaximumFractionDigits()); String LocaleNegativePrefix = new DecimalFormat().getNegativePrefix(); String LocaleNegativeSuffix =new DecimalFormat().getNegativeSuffix(); String Operator = Utils.getQwnername(context);
String positiveSuffix = decimalFormat.getPositiveSuffix(); String negativePrefix = decimalFormat.getNegativePrefix(); String negativeSuffix = decimalFormat.getNegativeSuffix();
@Override public boolean isPercent() { NumberFormat percentNF = BEANS.get(NumberFormatProvider.class).getPercentInstance(NlsLocale.get()); if (percentNF instanceof DecimalFormat) { DecimalFormat percentDF = (DecimalFormat) percentNF; DecimalFormat internalDF = getFormatInternal(); return internalDF.getPositiveSuffix().equals(percentDF.getPositiveSuffix()) && internalDF.getNegativeSuffix().equals(percentDF.getNegativeSuffix()); } else { throw new NumberFormatException(); } }
@Override public boolean isPercent() { DecimalFormat percentDF = BEANS.get(NumberFormatProvider.class).getPercentInstance(NlsLocale.get()); DecimalFormat internalDF = getFormatInternal(); return internalDF.getPositiveSuffix().equals(percentDF.getPositiveSuffix()) && internalDF.getNegativeSuffix().equals(percentDF.getNegativeSuffix()); }
private String ensureSuffix(String text) { String positiveSuffix = getFormatInternal().getPositiveSuffix(); String negativeSuffix = getFormatInternal().getNegativeSuffix(); if (positiveSuffix.equals(negativeSuffix)) { String trimmedSuffix = StringUtility.trim(positiveSuffix); if (text.endsWith(trimmedSuffix)) { text = StringUtility.trim(text.substring(0, text.length() - trimmedSuffix.length())); } text = StringUtility.concatenateTokens(text, positiveSuffix); } return text; }
public static String numberToCurrencyString(Number damount, boolean bCurrencySign, EscapeFunction f) { LanguageSetting s = languageProvider.vend(); String rv; DecimalFormat d = (DecimalFormat) NumberFormat.getCurrencyInstance(s.locale); if (damount.doubleValue() < 0) { if (d.getNegativePrefix().contains("(")) d.setNegativePrefix(d.getNegativePrefix().replace("(", "-")); if (d.getNegativeSuffix().contains(")")) d.setNegativeSuffix(d.getNegativeSuffix().replace(")", "")); } if (!bCurrencySign) { d.setPositivePrefix(""); d.setPositiveSuffix(""); d.setNegativePrefix("-"); d.setNegativeSuffix(""); } rv = d.format(damount.doubleValue()); rv.replace((char) 160, ' '); return f.escape(rv); }
@Override protected NumberSymbols createObject(Locale locale, NumberType numberType, Object... params) throws Exception { DecimalFormat df = null; switch (numberType) { case INTEGER: df = (DecimalFormat) DecimalFormat.getIntegerInstance(locale); break; case PERCENT: df = (DecimalFormat) DecimalFormat.getPercentInstance(locale); break; case DECIMAL: default: df = (DecimalFormat) DecimalFormat.getNumberInstance(locale); break; } DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); return new NumberSymbols(numberType, df.getNegativePrefix(), df.getNegativeSuffix(), df.getPositivePrefix(), df.getPositiveSuffix(), df.getGroupingSize(), dfs.getGroupingSeparator(), dfs.getDecimalSeparator()); } };
@Override public void setPercent(boolean b) { DecimalFormat percentDF = BEANS.get(NumberFormatProvider.class).getPercentInstance(NlsLocale.get()); DecimalFormat format = getFormat(); if (b) { format.setPositiveSuffix(percentDF.getPositiveSuffix()); format.setNegativeSuffix(percentDF.getNegativeSuffix()); } else { if (isPercent()) { format.setPositiveSuffix(""); format.setNegativeSuffix(""); } } setFormat(format); }
@Override public void setPercent(boolean b) { try { DecimalFormat percentDF = BEANS.get(NumberFormatProvider.class).getPercentInstance(NlsLocale.get()); DecimalFormat format = getFormat(); if (b) { format.setPositiveSuffix(percentDF.getPositiveSuffix()); format.setNegativeSuffix(percentDF.getNegativeSuffix()); } else { if (isPercent()) { format.setPositiveSuffix(""); format.setNegativeSuffix(""); } } setFormat(format); } finally { setFieldChanging(false); } }