Re: Formatting a BigDecimal in a WOString
Re: Formatting a BigDecimal in a WOString
- Subject: Re: Formatting a BigDecimal in a WOString
- From: Chuck Hill <email@hidden>
- Date: Fri, 7 Nov 2008 17:43:43 -0800
On Nov 7, 2008, at 3:49 PM, Paul Hoadley wrote:
Hello,
I'm having trouble getting a WOString to format a
java.math.BigDecimal. Here's an example of what I'm doing:
sumString : WOString {
value = stats.sum;
numberformat = numberFormat;
}
'stats.sum' returns a BigDecimal. 'numberFormat' returns the string
'#.######'---my intention is to display the BigDecimal in standard
(non-scientific) notation, to a maximum of 6 decimal places. If I
have 'stats.sum' returning a value in scientific notation, say "2.8E
+2", it passes through the number formatter unaffected, and the
string "2.8E+2" is displayed on the page. If I change 'value' to
'stats.sum.toPlainString' and comment out the 'numberformat' line, I
get the value in standard notation, but then if I have a number
with, say, 10 decimal places, it obviously no longer gets truncated
as desired. What's the best way around this?
Punt? I might be a bug in NSNumberFormatter. I usually use the
formatter binding rather than the format string bindings (dateFormat
and numberFormat). You could try that and pass back an instance of a
Java formatter, e.g. java.text.NumberFormat.
Chuck
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden