return -1; if (!isAllowFractions() || format.isParseIntegerOnly()) { return 0;
@Override public long parseLong(String value, boolean roundUp, LongSupplier now) { Number n; try { n = format.parse(value); } catch (ParseException e) { throw new RuntimeException(e); } if (format.isParseIntegerOnly()) { return n.longValue(); } else { double d = n.doubleValue(); if (roundUp) { d = Math.ceil(d); } else { d = Math.floor(d); } return Math.round(d); } }
/** * Returns true if this format will parse numbers as integers only. * For example in the English locale, with ParseIntegerOnly true, the * string "1234." would be parsed as the integer value 1234 and parsing * would stop at the "." character. The decimal separator accepted * by the parse operation is locale-dependent and determined by the * subclass. * @return true if this will parse integers only * @stable ICU 2.0 */ public boolean isParseIntegerOnly() { return numberFormat.isParseIntegerOnly(); }
@Override public boolean isParseIntegerOnly() { return fJdkNfmt.isParseIntegerOnly(); }
/** * Returns true if this format will parse numbers as integers only. * For example in the English locale, with ParseIntegerOnly true, the * string "1234." would be parsed as the integer value 1234 and parsing * would stop at the "." character. The decimal separator accepted * by the parse operation is locale-dependent and determined by the * subclass. * @return true if this will parse integers only * @stable ICU 2.0 */ public boolean isParseIntegerOnly() { return numberFormat.isParseIntegerOnly(); }
@Override public long parseLong(String value, boolean roundUp, LongSupplier now) { Number n; try { n = format.parse(value); } catch (ParseException e) { throw new RuntimeException(e); } if (format.isParseIntegerOnly()) { return n.longValue(); } else { double d = n.doubleValue(); if (roundUp) { d = Math.ceil(d); } else { d = Math.floor(d); } return Math.round(d); } }
@Override public long parseLong(String value, boolean roundUp, LongSupplier now) { Number n; try { n = format.parse(value); } catch (ParseException e) { throw new RuntimeException(e); } if (format.isParseIntegerOnly()) { return n.longValue(); } else { double d = n.doubleValue(); if (roundUp) { d = Math.ceil(d); } else { d = Math.floor(d); } return Math.round(d); } }
@Override public long parseLong(String value, boolean roundUp, LongSupplier now) { Number n; try { n = format.parse(value); } catch (ParseException e) { throw new RuntimeException(e); } if (format.isParseIntegerOnly()) { return n.longValue(); } else { double d = n.doubleValue(); if (roundUp) { d = Math.ceil(d); } else { d = Math.floor(d); } return Math.round(d); } }
@Override public long parseLong(String value, boolean roundUp, LongSupplier now) { Number n; try { n = format.parse(value); } catch (ParseException e) { throw new RuntimeException(e); } if (format.isParseIntegerOnly()) { return n.longValue(); } else { double d = n.doubleValue(); if (roundUp) { d = Math.ceil(d); } else { d = Math.floor(d); } return Math.round(d); } }
if (minimum_ < 1E-3 && minimum_ > -1E-3 && step <= 1E-3 && !format_.isParseIntegerOnly()) { sci = true; step = step * XMath.pow10(-XMath.log10(step)); ((DecimalFormat) format_).applyPattern("0.###E0"); precision++; } else if (!format_.isParseIntegerOnly()) { ((DecimalFormat) format_).applyPattern("0.00");
postfix = numberFormat.getCurrency().getCurrencyCode(); if (type == null) { if (numberFormat.isParseIntegerOnly()) { parsingType = (Class<T>) Integer.class; } else {
@Override public boolean equals(Object obj) { if (obj == null) return false; if (this == obj) return true; if (getClass() != obj.getClass()) return false; NumberFormat that = (NumberFormat) obj; return ( getMaximumIntegerDigits() == that.getMaximumIntegerDigits() && getMinimumIntegerDigits() == that.getMinimumIntegerDigits() && getMaximumFractionDigits() == that.getMaximumFractionDigits() && getMinimumFractionDigits() == that.getMinimumFractionDigits() && isGroupingUsed() == that.isGroupingUsed() && isParseIntegerOnly() == that.isParseIntegerOnly() ); }
return -1; if (!isAllowFractions() || format.isParseIntegerOnly()) { return 0;
@Test public void testIsParseIntegerOnly () { if (verifyNoPropertyViolation()) { DecimalFormat dFormat = new DecimalFormat(); assertFalse(dFormat.isParseIntegerOnly()); dFormat.setParseIntegerOnly(true); assertTrue(dFormat.isParseIntegerOnly()); dFormat.setParseIntegerOnly(false); assertFalse(dFormat.isParseIntegerOnly()); NumberFormat format = NumberFormat.getIntegerInstance(); assertTrue(format.isParseIntegerOnly()); format = NumberFormat.getNumberInstance(); assertFalse(format.isParseIntegerOnly()); format = NumberFormat.getNumberInstance(Locale.ENGLISH); assertFalse(format.isParseIntegerOnly()); } }
return -1; if (!isAllowFractions() || format.isParseIntegerOnly()) { return 0;