tags:

views:

2332

answers:

2

Here is an example:

    <h:outputText value="#{myBean.myMoney}">
       <f:convertNumber type="currency" currencySymbol="$" />
    </h:outputText>

Given that I have $1.006, will this output $1.00 or $1.01?

Doesn't say here: http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/tlddocs/f/convertNumber.html

+1  A: 

Answer=Rounded

Hmmm....does that sound right? I don't think its a good idea to be rounding up money. Hopefully no banking apps are going to rely on this one.

Brings to mind this scene from One Flew Over the Cuckoo's Nest and posted on imdb.

[the inmates are playing cards and betting with cigarettes]
Martini: [rips a cigarette in half] I bet a nickel.
McMurphy: Dime's the limit, Martini.
Martini: I bet a dime.
[Puts the two halves onto the table]
McMurphy: This is not a dime, Martini. This is a dime.
[shows a whole cigarette]
McMurphy: If you break it in half, you don't get two nickels, you get shit. Try and smoke it. You understand?
Martini: Yes.
McMurphy: You don't understand.

s_t_e_v_e
+2  A: 

Currency can be set only to 2 decimal places, setting it to more than 2 decimal places is wrong. If the input is with more than 2 decimal places the output would be truncated to 2 decimal places.

Logically $1.001 would not make any sense as $1 and 1 cent would be $1.01 not $1.001.

Warrior
Although, I agree with your response, I was looking for specifically how the convertNumber tag behaved. After testing it, I know that it is rounding. The fact that it is getting passed invalid data is another issue altogether.
s_t_e_v_e