nf.setMaximumFractionDigits(4); if (nf instanceof DecimalFormat) { ((DecimalFormat) nf).setPositivePrefix(" ");
nf.setMaximumFractionDigits(2); if (nf instanceof DecimalFormat) { ((DecimalFormat) nf).setPositivePrefix(" ");
nf.setMaximumFractionDigits(2); if (nf instanceof DecimalFormat) { ((DecimalFormat) nf).setPositivePrefix(" ");
nf.setMaximumFractionDigits(4); if (nf instanceof DecimalFormat) { ((DecimalFormat) nf).setPositivePrefix(" ");
/** * Sets the positive prefix. * * <p>Examples: +123, $123, sFr123 * @param newValue the prefix * @stable ICU 2.0 */ public void setPositivePrefix(String newValue) { ((java.text.DecimalFormat)numberFormat).setPositivePrefix(newValue); }
fmt.setPositivePrefix("+");
/** * Sets the positive prefix. * * <p>Examples: +123, $123, sFr123 * @param newValue the prefix * @stable ICU 2.0 */ public void setPositivePrefix(String newValue) { ((java.text.DecimalFormat)numberFormat).setPositivePrefix(newValue); }
@Override protected NumberFormat initialValue() { DecimalFormat ldf = (DecimalFormat) NumberFormat.getNumberInstance(Locale.ENGLISH); ldf.applyPattern(PATTERN); ldf.setPositivePrefix("+"); return ldf; } };
StockAdapter(Context context, StockAdapterOnClickHandler clickHandler) { this.context = context; this.clickHandler = clickHandler; dollarFormat = (DecimalFormat) NumberFormat.getCurrencyInstance(Locale.US); dollarFormatWithPlus = (DecimalFormat) NumberFormat.getCurrencyInstance(Locale.US); dollarFormatWithPlus.setPositivePrefix("+$"); percentageFormat = (DecimalFormat) NumberFormat.getPercentInstance(Locale.getDefault()); percentageFormat.setMaximumFractionDigits(2); percentageFormat.setMinimumFractionDigits(2); percentageFormat.setPositivePrefix("+"); }
DecimalFormat fmt = (DecimalFormat) NumberFormat.getInstance(); fmt.setGroupingUsed(true); fmt.setPositivePrefix("Rs. "); fmt.setNegativePrefix("Rs. -"); fmt.setMinimumFractionDigits(2); fmt.setMaximumFractionDigits(2); fmt.format(30382.50);
public ExponentialFormat( int digits, int exp, boolean sign, boolean trailing ) { this.digits = digits; this.exp = exp; this.sign = sign; this.trailing = trailing; nf = new DecimalFormat( pattern() ); nf.setPositivePrefix("+"); nf.setNegativePrefix("-"); }
/** * Returns a string representation of this equation system. * * @param prefix the prefix of each line * @param fractionDigits the number of fraction digits for output accuracy * @return a string representation of this equation system */ public String equationsToString(String prefix, int fractionDigits) { DecimalFormat nf = new DecimalFormat(); nf.setMinimumFractionDigits(fractionDigits); nf.setMaximumFractionDigits(fractionDigits); nf.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US)); nf.setNegativePrefix(""); nf.setPositivePrefix(""); return equationsToString(prefix, nf); }
public FloatingPointFormat( int w, int d ) { width = w; decimal = d; nf = new DecimalFormat( pattern(w, d) ); nf.setPositivePrefix(" "); nf.setNegativePrefix("-"); }
public static String moneyFormatter(double d){ DecimalFormat fmt = (DecimalFormat) NumberFormat.getInstance(); Locale locale = Locale.getDefault(); String symbol = Currency.getInstance(locale).getSymbol(locale); fmt.setGroupingUsed(true); fmt.setPositivePrefix(symbol + " "); fmt.setNegativePrefix("-" + symbol + " "); fmt.setMinimumFractionDigits(2); fmt.setMaximumFractionDigits(2); return fmt.format(d); }
/** * Returns a string representation of this equation system. * * @param prefix the prefix of each line * @param fractionDigits the number of fraction digits for output accuracy * @return a string representation of this equation system */ public String equationsToString(String prefix, int fractionDigits) { DecimalFormat nf = new DecimalFormat(); nf.setMinimumFractionDigits(fractionDigits); nf.setMaximumFractionDigits(fractionDigits); nf.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US)); nf.setNegativePrefix(""); nf.setPositivePrefix(""); return equationsToString(prefix, nf); }
/** * Returns a string representation of this equation system. * * @param prefix the prefix of each line * @param fractionDigits the number of fraction digits for output accuracy * @return a string representation of this equation system */ public String equationsToString(String prefix, int fractionDigits) { DecimalFormat nf = new DecimalFormat(); nf.setMinimumFractionDigits(fractionDigits); nf.setMaximumFractionDigits(fractionDigits); nf.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US)); nf.setNegativePrefix(""); nf.setPositivePrefix(""); return equationsToString(prefix, nf); }
public ExponentialFormat( int digits, int exp, boolean sign, boolean trailing ) { this.digits = digits; this.exp = exp; this.sign = sign; this.trailing = trailing; nf = new DecimalFormat( pattern() ); nf.setPositivePrefix("+"); nf.setNegativePrefix("-"); }
public FloatingPointFormat( int w, int d ) { width = w; decimal = d; nf = new DecimalFormat( pattern(w, d) ); nf.setPositivePrefix(" "); nf.setNegativePrefix("-"); }
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); }
private Format numberFormat(Locale l, char conversion, Flags flags, boolean integer, int length, int precision, boolean isUpper) { precision = (precision == -1 ? 6 : precision); DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(l); symbols.setExponentSeparator( isUpper ? "E" : "e"); symbols.setDigit(flags.zeropadded ? '0' : '#'); int fixed = (integer ? length : length - precision); DecimalFormat df = new DecimalFormat("#" + (conversion == 'e' ? "E00" : ""), symbols); if(flags.grouping) { df.setGroupingUsed(true); df.setGroupingSize(3); } if(flags.parenthesis) { df.setNegativePrefix("("); df.setNegativeSuffix(")"); } if(flags.withsign) { df.setPositivePrefix("+");; } if(! integer) { df.setMinimumFractionDigits(precision); } if(symbols.getDigit() == '0') { df.setMinimumIntegerDigits(fixed); } if(flags.leftjustified) { return new LeftJustifyFormat(df, length); } else { return new RightJustifyFormat(df, length); } }