[xwiki-users] Convert String to Integer in Velocity
Hi, is it possible to convert a String to Integer in Velocity? I tried with Groovy but I don't know how to do with Velocity. -- Ngô Thị Hồng Nga
Hi, Yes you can use the velocity Math tool: http://velocity.apache.org/tools/devel/generic/MathTool.html It's configured by default in XE 1.4M2 (being released right now) so you'll only have to do: $mathtool.toInteger("10") -Vincent On Apr 25, 2008, at 7:20 PM, Ngo Thi Hong Nga wrote:
Hi, is it possible to convert a String to Integer in Velocity? I tried with Groovy but I don't know how to do with Velocity.
Vincent Massol wrote:
Hi,
Yes you can use the velocity Math tool: http://velocity.apache.org/tools/devel/generic/MathTool.html
It's configured by default in XE 1.4M2 (being released right now) so you'll only have to do:
$mathtool.toInteger("10")
Or the older $xwiki.parseInt("42") or the newer $util.parseInt("007"). Looking at com.xpn.xwiki.api.Util, there's also parseDouble, parseFloat, parseLong and parseInteger (returns an Integer object, not a primitive).
-Vincent
On Apr 25, 2008, at 7:20 PM, Ngo Thi Hong Nga wrote:
Hi, is it possible to convert a String to Integer in Velocity? I tried with Groovy but I don't know how to do with Velocity.
-- Sergiu Dumitriu http://purl.org/net/sergiu/
thanks On Sat, Apr 26, 2008 at 7:09 AM, Sergiu Dumitriu <sergiu@xwiki.com> wrote:
Vincent Massol wrote:
Hi,
Yes you can use the velocity Math tool: http://velocity.apache.org/tools/devel/generic/MathTool.html
It's configured by default in XE 1.4M2 (being released right now) so you'll only have to do:
$mathtool.toInteger("10")
Or the older $xwiki.parseInt("42") or the newer $util.parseInt("007").
Looking at com.xpn.xwiki.api.Util, there's also parseDouble, parseFloat, parseLong and parseInteger (returns an Integer object, not a primitive).
-Vincent
On Apr 25, 2008, at 7:20 PM, Ngo Thi Hong Nga wrote:
Hi, is it possible to convert a String to Integer in Velocity? I tried with Groovy but I don't know how to do with Velocity.
-- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
-- Ngô Thị Hồng Nga Mobile: 0935 176133
participants (3)
-
Ngo Thi Hong Nga -
Sergiu Dumitriu -
Vincent Massol