setMaximumIntegerDigits(super.getMaximumIntegerDigits()); setMinimumIntegerDigits(super.getMinimumIntegerDigits()); setMaximumFractionDigits(super.getMaximumFractionDigits());
/** * Sets the maximum number of digits allowed in the integer portion of a number. * For formatting numbers other than BigInteger and BigDecimal objects, the lower * of newValue and 309 is used. Negative input values are replaced with 0. */ public void setMaximumIntegerDigits(int maximumIntegerDigits){ format.setMaximumIntegerDigits(maximumIntegerDigits); }
/** * Sets the maximum number of digits allowed in the integer portion of a * number. */ public void setMaximumIntegerDigits(int newValue) { decimalFormat.setMaximumIntegerDigits(newValue); scientificFormat.setMaximumIntegerDigits(newValue); this.maxIntDigits = newValue; }
double number = (double)17/3; java.text.DecimalFormat number_format = new java.text.DecimalFormat("#.###"); number_format.setMaximumIntegerDigits(0); System.out.println(number); String formatted_string = number_format.format(number); System.out.println(formatted_string);
DecimalFormat decimalFormat = new DecimalFormat(); decimalFormat.setMaximumIntegerDigits(Integer.MAX_VALUE); // don't use grouping for numeric-type cells decimalFormat.setGroupingUsed(false); decimalFormat.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US)); value = decimalFormat.format(numericValue);
DecimalFormatSymbols symbols = new DecimalFormatSymbols(); symbols.setGroupingSeparator(' '); symbols.setDecimalSeparator(','); String pattern = "#,##0.###"; DecimalFormat decimalFormat = new DecimalFormat( pattern, symbols ); decimalFormat.setMaximumIntegerDigits(19); decimalFormat.setMaximumFractionDigits(2); System.out.println( decimalFormat.format( 12345.67 ) );
private TypeFormatter(int prec) { _prec = prec; _df.setMaximumIntegerDigits(prec); _df.setMaximumFractionDigits(prec); _df.setRoundingMode(ROUND_MODE); _dfS = createScientificFormat(prec); }
@Override protected DecimalFormat initialValue() { DecimalFormat format = new DecimalFormat(); format.setGroupingUsed(false); format.setMinimumIntegerDigits(14); format.setMaximumIntegerDigits(14); format.setMinimumFractionDigits(3); format.setMaximumFractionDigits(3); DecimalFormatSymbols formatSymbols = new DecimalFormatSymbols(); formatSymbols.setDecimalSeparator('.'); format.setDecimalFormatSymbols(formatSymbols); return format; } };
private void printResolution(StringBuffer buf){ if (getResolution() == DEFAULT_RESOLUTION){ return; } DecimalFormat d2 = (DecimalFormat)NumberFormat.getInstance(java.util.Locale.UK); d2.setMaximumIntegerDigits(2); d2.setMinimumFractionDigits(2); d2.setMaximumFractionDigits(2); buf.append("REMARK 2 RESOLUTION. "); String x = d2.format(resolution); buf.append(x); buf.append(" ANGSTROMS."); fillLine(buf,34+x.length()); buf.append(newline); }
private static ScientificFormat createScientificFormat(int prec) { DecimalFormat df = new DecimalFormat("0.#E00"); df.setMaximumIntegerDigits(1); df.setMaximumFractionDigits(prec); df.setRoundingMode(ROUND_MODE); return new ScientificFormat(df); }
public String toString() { final DecimalFormat nf = new DecimalFormat("##.###E0"); nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2); nf.setMinimumIntegerDigits(1); nf.setMaximumIntegerDigits(1); nf.setGroupingUsed(false); final StringBuffer res = new StringBuffer(100); res.append("RepereEvent()\n[(val, rel, chg) (val, rel, chg) (val, rel, chg)]\n"); for (int i = 0; i < 4; i++) { res.append('['); for (int j = 0; j < 3; j++) { res.append(" (").append(nf.format(valeur_[i][j])).append(", ").append((relatif_[i][j] ? "1" : "0")) .append(", ").append((aChange_[i][j] ? "1" : "0")).append(") "); } res.append("]\n"); } return res.toString(); }
@Override public void setMaxIntegerDigits(int maxIntegerDigits) { DecimalFormat format = getFormat(); format.setMaximumIntegerDigits(maxIntegerDigits); setFormat(format); }
/** print the idx positions of this alignment * * @return a String representation */ @Override public String toString(){ DecimalFormat d2 = new DecimalFormat(); // the result can be localized. To change this and enforce UK local do... //(DecimalFormat)NumberFormat.getInstance(java.util.Locale.UK); d2.setMaximumIntegerDigits(3); d2.setMinimumFractionDigits(2); d2.setMaximumFractionDigits(2); StringBuffer s = new StringBuffer(); s.append("#" + getAltAligNumber() + " cluster:" + cluster + " eqr:" + getEqr() + " rmsd:" + d2.format(getRmsd()) + " %id:" + getPercId() + " gaps:" + getGaps() + " score:" + d2.format(score) ); return s.toString(); }
/** * Constructs a FloatField with the default values and initialized to 0.0. */ public FloatField() { super(11); setDocument(new TexCoordDocument()); formatter = new DecimalFormat(); formatter.setMaximumFractionDigits(6); formatter.setMinimumFractionDigits(1); formatter.setMaximumIntegerDigits(6); formatter.setDecimalSeparatorAlwaysShown(true); formatter.setGroupingUsed(false); setValue(0.0f); }
@Override public void setMaxIntegerDigits(int maxIntegerDigits) { try { DecimalFormat format = getFormat(); format.setMaximumIntegerDigits(maxIntegerDigits); setFormat(format); } finally { setFieldChanging(false); } }
protected void initFormat() { DecimalFormat format = BEANS.get(NumberFormatProvider.class).getNumberInstance(NlsLocale.get()); format.setParseBigDecimal(true); format.setMinimumFractionDigits(0); format.setMaximumFractionDigits(0); format.setMaximumIntegerDigits(getConfiguredMaxIntegerDigits()); propertySupport.setProperty(INumberValueContainer.PROP_DECIMAL_FORMAT, format); }
protected void initFormat() { DecimalFormat format = BEANS.get(NumberFormatProvider.class).getNumberInstance(NlsLocale.get()); format.setParseBigDecimal(true); format.setMinimumFractionDigits(0); format.setMaximumFractionDigits(0); format.setMaximumIntegerDigits(getConfiguredMaxIntegerDigits()); propertySupport.setProperty(INumberValueContainer.PROP_DECIMAL_FORMAT, format); }
/** * Constructs a FloatField with the default values and initialized with a * value. * * @param value * The intitial float value the field will display. */ public FloatField(float value) { super(11); setDocument(new TexCoordDocument()); formatter = new DecimalFormat(); formatter.setMaximumFractionDigits(6); formatter.setMinimumFractionDigits(1); formatter.setMaximumIntegerDigits(6); formatter.setDecimalSeparatorAlwaysShown(true); formatter.setGroupingUsed(false); setValue(value); }
/** * @param dfs The decimal format symbols * * @return A decimal format suitable for Bitcoin balance representation */ private static DecimalFormat configureBitcoinDecimalFormat(DecimalFormatSymbols dfs, BitcoinSymbol bitcoinSymbol, boolean showNegative) { DecimalFormat format = new DecimalFormat(); format.setDecimalFormatSymbols(dfs); format.setMaximumIntegerDigits(16); format.setMinimumIntegerDigits(1); format.setMaximumFractionDigits(bitcoinSymbol.decimalPlaces()); format.setMinimumFractionDigits(bitcoinSymbol.decimalPlaces()); format.setDecimalSeparatorAlwaysShown(false); if (showNegative) { format.setNegativePrefix("-"); } else { format.setNegativePrefix(""); } return format; }
/** * Constructs a FloatField with the default values and initialized with a * value. * * @param value * The intitial float value the field will display. * @param enabled * Indicates if the field should initially be enabled for * editing. */ public FloatField(float value, boolean enabled) { super(11); setDocument(new TexCoordDocument()); formatter = new DecimalFormat(); formatter.setMaximumFractionDigits(6); formatter.setMinimumFractionDigits(1); formatter.setMaximumIntegerDigits(6); formatter.setDecimalSeparatorAlwaysShown(true); formatter.setGroupingUsed(false); setValue(value); setEnabled(enabled); }