1

I have an object - call this "order" This object has a property - Total. This is type - decimal (it's a money value)

In my template i have something like:

Order Total: $order.Total GBP

However, in the resulting merge, it comes out as:

Order Total: 3.4000 GBP

for 3.40

Is there any way of telling nvelocity to format it as 2 decimal places??

Alex
  • 37,502
  • 51
  • 204
  • 332

2 Answers2

2

I found it out:

Can use ToString("N2") for example:

Order Total: $order.Total.ToString("N2") GBP

Alex
  • 37,502
  • 51
  • 204
  • 332
0

Some additional explanation about variable formatting in Nvelocity:

When you reference variables you are accessing the object through the .NET framework. You can use traditional .NET syntax to access properties and methods. You can use this to perform string formatting:

$User.LastLoginDate.ToString("mm-ddd-yyyy")

Remko Jansen
  • 4,649
  • 4
  • 30
  • 39