Question

Using FreeMarker, I want to display a date into milliseconds:

${mydate?long}

but I get as output a comma separated millisecond:

524,354,400,000

is there any built-in function in Freemarker to remove comma ?

Thanks

Was it helpful?

Solution

It looks like as of version 2.3.17 you can use:

${myDate?long?c}

http://sourceforge.net/p/freemarker/feature-requests/72/

OTHER TIPS

As an alternative you could write on your Freemarker template this directive:

<#setting number_format="computer">

This will remove all commas from numbers.

This works fine for Freemarker 2.3.23

More info about these directives can be found here:

http://freemarker.org/docs/ref_directive_setting.html

Adding to Gil's answer, if you build the configuration inside your code, you can set the flag globally by :

Configuration cfg = new Configuration();
...
cfg.setNumberFormat("computer");

Copied from the comment of the accepted answer,

In my version (2.3.26), simply ${myDate?c} will suffice, assuming that myDate is already a long/int.

This is worked for me

Thank you

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top