Re: How to convert string in int
Hi, have you tried the Integer class methods: ## create an integer instance to be used as a tool #set( $Integer = 0 ) ##... ## retrieve your number string #set( $countString = $!data.getRequest().getParameter(countRow) ) ## convert it to an Integer #set( $count = $Integer.parseInt($countString) ) Cheers, :) Christoph tarun Narang wrote: Hi Can anyone tell me that how the string can be converted into int in VTL I am recieving the value in count variable through getRequest but this variable has a string value and i have to add some int value in this count variable like $count + 5. #set ($count = $!data.getRequest().getParameter(countRow)) Thanks Tarun - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to convert string in int
hi Thanks its working now with MathTool - Original Message - From: Christoph Reck [EMAIL PROTECTED] To: Velocity Users List velocity-user@jakarta.apache.org Sent: Thursday, March 24, 2005 1:33 PM Subject: Re: How to convert string in int Hi, have you tried the Integer class methods: ## create an integer instance to be used as a tool #set( $Integer = 0 ) ##... ## retrieve your number string #set( $countString = $!data.getRequest().getParameter(countRow) ) ## convert it to an Integer #set( $count = $Integer.parseInt($countString) ) Cheers, :) Christoph tarun Narang wrote: Hi Can anyone tell me that how the string can be converted into int in VTL I am recieving the value in count variable through getRequest but this variable has a string value and i have to add some int value in this count variable like $count + 5. #set ($count = $!data.getRequest().getParameter(countRow)) Thanks Tarun - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to convert string in int
tarun Narang [EMAIL PROTECTED] wrote: Can anyone tell me that how the string can be converted into int in VTL I am recieving the value in count variable through getRequest but this variable has a string value and i have to add some int value in this count variable like $count + 5. #set ($count = $!data.getRequest().getParameter(countRow)) It's only necessary to ask a question once, by the way. I'd perform this conversion using the NumberTool. ie, once you have $numberTool installed in your context, $numberTool.toNumber($count) -- The result of this operation will be of class Number http://jakarta.apache.org/velocity/tools/generic/ http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/generic/NumberTool.html Note that tools like NumberTool are just plain old java objects, and you can put them into your context in many ways, the easiest of which is. context.put(numberTool, new org.apache.velocity.tools.generic.NumberTool()); -Mike - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to convert string in int
its working but its not work with NumberTool its properly runs by using MathTool Thanks - Original Message - From: Mike Kienenberger [EMAIL PROTECTED] To: Velocity Users List velocity-user@jakarta.apache.org Cc: Velocity Users List velocity-user@jakarta.apache.org Sent: Wednesday, March 23, 2005 11:37 PM Subject: Re: How to convert string in int tarun Narang [EMAIL PROTECTED] wrote: Can anyone tell me that how the string can be converted into int in VTL I am recieving the value in count variable through getRequest but this variable has a string value and i have to add some int value in this count variable like $count + 5. #set ($count = $!data.getRequest().getParameter(countRow)) It's only necessary to ask a question once, by the way. I'd perform this conversion using the NumberTool. ie, once you have $numberTool installed in your context, $numberTool.toNumber($count) -- The result of this operation will be of class Number http://jakarta.apache.org/velocity/tools/generic/ http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/g eneric/NumberTool.html Note that tools like NumberTool are just plain old java objects, and you can put them into your context in many ways, the easiest of which is. context.put(numberTool, new org.apache.velocity.tools.generic.NumberTool()); -Mike - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]