webtier@glassfish.java.net

Re: [webtier] JSF Converter question

From: <webtier_at_javadesktop.org>
Date: Mon, 14 Jul 2008 10:04:18 PDT

This is per the javadocs for DecimalFormat:

"If isParseBigDecimal() is false (the default), most integer values are returned as Long objects, no matter how they are written: "17" and "17.000" both parse to Long(17). Values that cannot fit into a Long are returned as Doubles. This includes values with a fractional part, infinite values, NaN, and the value -0.0. DecimalFormat does not decide whether to return a Double or a Long based on the presence of a decimal separator in the source string. Doing so would prevent integers that overflow the mantissa of a double, such as "-9,223,372,036,854,775,808.00", from being parsed accurately."

The best way to deal with this is to have your properties accept/return Number instances and then
in your processing logic call Number.doubleValue().
[Message sent by forum member 'rlubke' (rlubke)]

http://forums.java.net/jive/thread.jspa?messageID=286485