问题
I have a string with commas in between. How should I convert this string into an integer. I tried using
x?number
but that gives me the following error
Exceptionfreemarker.core.NonNumericalException
e.g. The string is "453,000". I need to convert this to 453000.
Is there any other way of doing this?
回答1:
There's no function built in for parsing numbers with national formats. ?number
only deals with computer format, because when numbers are transferred as strings (which should be already rare), that's what used to be used. So in principle x
should be already a number when it gets to FreeMarker, or at least it should use computer format. If that's not possible, you will need a custom function (or method) for that.
来源:https://stackoverflow.com/questions/39838953/convert-string-with-commas-into-integer-in-freemarker