I wanted to be able to output a decimal value from an object in my NVelocity template.
For example, the value of the decimal was: 3.40000 to represent 3.4.
The end result:
Total Order Value: 3.40 GBP
I needed to display this as currency format. Sure, I could of used this String.Format method, but that adds £ or $ or whatever (depending on your environment setup) to the start of the resulting string.
In the end, I used ToString with “N2” formatter.
So, in my nVelocity template, here is what I would use:
Total Order Value: $Order.GrandTotal.ToString("N2") GBP
There are some other alternatives discussed here:
http://stackoverflow.com/questions/1048643/format-a-double-value-like-currency-but-without-the-currency-sign-c
Leave a Reply