Re: currency format for negative number
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Tuesday, June 2, 2009, 1:48:28 PM, strutstwouser wrote:
>
> I have a related question on currency formatting ; thought i'll add to this
> post instead of adding a new one..
>
> How do i currency-format a String value? . i.e i have
> pointsAndLender.getValue() returning a String, not a BigDecimal and i can't
> control this design .
>
> ${pointsAndLender.value?number?string.currency} works , but wanted to make
> sure this is the best way to do it. It seems a little weird to convert a
> string to number and then to string again..Please confirm
There is nothing strange in it. For formatting something, the program
has to "understand" it first, be it FreeMarker or not.
> Thanks,
> joseph
>
>
>
>
>
>
>
>
>
> Daniel Dekany wrote:
>>
>> Thursday, May 21, 2009, 11:28:35 PM, Scott Purcell wrote:
>>
>>> Hello,
>>>
>>> I have the following
>>> Adjustment Amount: ${adjustment.adjustmentAmount?string.currency!""}
>>>
>>> The adjustment.getAdjustmentAmount method returns a BigDecimal and
>>> all is good. Problem is the value for adjustment is -5.00.
>>> So when it prints to the email it prints ($5.00) which I thought
>>> was good, but the customer wants -$5.00.
>>>
>>> Can anyone assist with this?
>>
>> I'm afraid it's out of our reach... we call the currency formatting of
>> the Java platform. However, personally I just wouldn't build on
>> that... call me paranoid, but who knows what will be the default
>> format in the next release. And displaying money is exactly something
>> that better not have bugs. Rather write a TemplateMethodEx (or a
>> #function maybe) so you can reliably control how are things displayed.
>> You see, ${my.currency(adjustment.adjustmentAmount)} or something...
>>
>>> Thanks,
>>>
>>>
>>>
>>> CONFIDENTIALITY NOTICE
>>> This e-mail message and any attachments are only for the use of the
>>> intended recipient and may contain information that is privileged,
>>> confidential or exempt from disclosure under applicable law. If you
>>> are not the intended recipient, any disclosure, distribution or
>>> other use of this e-mail message or attachments is prohibited. If
>>> you have received this e-mail message in error, please delete and
>>> notify the sender immediately. Thank you.
>> --
>> Best regards,
>> Daniel Dekany
>>
>>
>> ------------------------------------------------------------------------------
>> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
>> is a gathering of tech-side developers & brand creativity professionals.
>> Meet
>> the minds behind Google Creative Lab, Visual Complexity, Processing, &
>> iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
>> Group, R/GA, & Big Spaceship. http://www.creativitycat.com
>> _______________________________________________
>> FreeMarker-user mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>>
>>
>
--
Best regards,
Daniel Dekany
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get