I'm printing currency values to the screen using <fmt:formatNumber>. If my numeric value has a non-zero fractional part I want exactly two decimal places. If the fractional part is zero I want the decimal places omitted.
so 45.75 prints as $45.75
but 201.00 prints as $201
So that means that 18.30 should print as $18.30 and not as $18.3? In that case I think you're going to need two different formatters and some kind if-then-else to distinguish the two cases. Writing a custom tag might be the right way to go here.
Ah. I thought that no-trailing was an undesirable outcome.
In that case, I'd simply use the ternary operator to choose between the two patterns.
Joined: Jan 20, 2008
Is there anything in the fn library that can perform decision in a robust way? All I can think of is to check if the String representation of the value ends with ".00", and that sounds ugly. BTW does Oracle have a documentation page for EL? Thank you.