if (numberFormat instanceof DecimalFormat) { decimalFormat = (DecimalFormat) numberFormat; if (BigDecimal.class == targetClass && !decimalFormat.isParseBigDecimal()) { decimalFormat.setParseBigDecimal(true); resetBigDecimal = true;
return null; if (this.isParseBigDecimal()) { if (number instanceof Long) { return new BigDecimal(number.longValue());
if (numberFormat instanceof DecimalFormat) { decimalFormat = (DecimalFormat) numberFormat; if (BigDecimal.class == targetClass && !decimalFormat.isParseBigDecimal()) { decimalFormat.setParseBigDecimal(true); resetBigDecimal = true;
if (numberFormat instanceof DecimalFormat) { decimalFormat = (DecimalFormat) numberFormat; if (BigDecimal.class.equals(targetClass) && !decimalFormat.isParseBigDecimal()) { decimalFormat.setParseBigDecimal(true); resetBigDecimal = true;
/** * Returns whether {@link #parse(String, ParsePosition)} returns BigDecimal. * * @return true if {@link #parse(String, ParsePosition)} returns BigDecimal. * @stable ICU 3.6 */ public boolean isParseBigDecimal() { return ((java.text.DecimalFormat)numberFormat).isParseBigDecimal(); }
/** * Returns whether {@link #parse(String, ParsePosition)} returns BigDecimal. * * @return true if {@link #parse(String, ParsePosition)} returns BigDecimal. * @stable ICU 3.6 */ public boolean isParseBigDecimal() { return ((java.text.DecimalFormat)numberFormat).isParseBigDecimal(); }
/** *Returns true if this format will parse, the value part, as {@link BigDecimal} only. */ public boolean isParseBigDecimal(){ return format.isParseBigDecimal(); } /**
/** * Converts the given text into a {@link BigDecimal}. * * @param text * @return a BigDecimal representation of the given text * @throws ConversionException if the text value can't be converted into * a valid {@link BigDecimal} */ private BigDecimal convert(DecimalFormat format, String text) throws ConversionException { if (format.isParseBigDecimal() == false) { throw new IllegalStateException("format must parse BigDecimal"); } text = text.trim(); if (text == null || text.length() == 0) { return null; } ParsePosition pos = new ParsePosition(0); BigDecimal result = (BigDecimal)format.parse(text, pos); if (result != null && pos.getIndex() == text.length()) { return result; } else { throw new ConversionException("Can't convert '" + text + "' to BigDecimal"); } }
return null; if (this.isParseBigDecimal()) { if (number instanceof Long) { return new BigDecimal(number.longValue());
return null; if (this.isParseBigDecimal()) { if (number instanceof Long) { return new BigDecimal(number.longValue());
return null; if (this.isParseBigDecimal()) { if (number instanceof Long) { return new BigDecimal(number.longValue());
return null; if (this.isParseBigDecimal()) { if (number instanceof Long) { return new BigDecimal(number.longValue());
public static <T extends Number> T parseNumber(String text, Class<T> targetClass, NumberFormat numberFormat) { if (numberFormat != null) { DecimalFormat decimalFormat = null; boolean resetBigDecimal = false; if (numberFormat instanceof DecimalFormat) { decimalFormat = (DecimalFormat) numberFormat; if (BigDecimal.class.equals(targetClass) && !decimalFormat.isParseBigDecimal()) { decimalFormat.setParseBigDecimal(true); resetBigDecimal = true; } } try { Number number = numberFormat.parse(trimAllWhitespace(text)); return convertNumberToTargetClass(number, targetClass); } catch (ParseException ex) { throw new IllegalArgumentException("Could not parse number: " + ex.getMessage()); } finally { if (resetBigDecimal && decimalFormat != null) { decimalFormat.setParseBigDecimal(false); } } } return parseNumber(text, targetClass); }
if (numberFormat instanceof DecimalFormat) { decimalFormat = (DecimalFormat) numberFormat; if (BigDecimal.class == targetClass && !decimalFormat.isParseBigDecimal()) { decimalFormat.setParseBigDecimal(true); resetBigDecimal = true;
if (numberFormat instanceof DecimalFormat) { decimalFormat = (DecimalFormat) numberFormat; if (BigDecimal.class == targetClass && !decimalFormat.isParseBigDecimal()) { decimalFormat.setParseBigDecimal(true); resetBigDecimal = true;
if (numberFormat instanceof DecimalFormat) { decimalFormat = (DecimalFormat) numberFormat; if (BigDecimal.class.equals(targetClass) && !decimalFormat.isParseBigDecimal()) { decimalFormat.setParseBigDecimal(true); resetBigDecimal = true;
if (numberFormat instanceof DecimalFormat) { decimalFormat = (DecimalFormat) numberFormat; if (BigDecimal.class == targetClass && !decimalFormat.isParseBigDecimal()) { decimalFormat.setParseBigDecimal(true); resetBigDecimal = true;
if (numberFormat instanceof DecimalFormat) { decimalFormat = (DecimalFormat) numberFormat; if (BigDecimal.class == targetClass && !decimalFormat.isParseBigDecimal()) { decimalFormat.setParseBigDecimal(true); resetBigDecimal = true;
if (numberFormat instanceof DecimalFormat) { decimalFormat = (DecimalFormat) numberFormat; if (BigDecimal.class.equals(targetClass) && !decimalFormat.isParseBigDecimal()) { decimalFormat.setParseBigDecimal(true); resetBigDecimal = true;
if (numberFormat instanceof DecimalFormat) { decimalFormat = (DecimalFormat) numberFormat; if (BigDecimal.class == targetClass && !decimalFormat.isParseBigDecimal()) { decimalFormat.setParseBigDecimal(true); resetBigDecimal = true;