You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by LaStudent <wg...@fh-landshut.de> on 2011/07/05 17:09:45 UTC

String to Number/Integer

Hello,

is it possible to convert a String to a Number?

something like this: 
#set($tmpStr = "14")
#set($tmpInt = parseInt($tmpStr))

best regards
-- 
View this message in context: http://old.nabble.com/String-to-Number-Integer-tp31997657p31997657.html
Sent from the Velocity - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: String to Number/Integer

Posted by Sergiu Dumitriu <se...@xwiki.com>.
On 07/05/2011 11:09 AM, LaStudent wrote:
>
> Hello,
>
> is it possible to convert a String to a Number?
>
> something like this:
> #set($tmpStr = "14")
> #set($tmpInt = parseInt($tmpStr))
>
> best regards

Not directly, but there's a tool for that:

http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/ConversionTool.html#toInteger%28java.lang.Object%29

-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: String to Number/Integer

Posted by Rachid <ra...@gmail.com>.
You can use Java classes for that.
For example Integer.parseInt()

Cheers,
Rachid.


On Tue, Jul 5, 2011 at 5:09 PM, LaStudent <wg...@fh-landshut.de> wrote:

>
> Hello,
>
> is it possible to convert a String to a Number?
>
> something like this:
> #set($tmpStr = "14")
> #set($tmpInt = parseInt($tmpStr))
>
> best regards
> --
> View this message in context:
> http://old.nabble.com/String-to-Number-Integer-tp31997657p31997657.html
> Sent from the Velocity - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

Re: String to Number/Integer

Posted by "Walker, Andrew" <a....@nature.com>.
Hi,

You can use:

#set($tmp = 0)
#set($tmpStr = "14")
#set($tmpInt = $tmp.parseInt($tmpStr))

Andrew

On 05/07/2011 16:09, "LaStudent" <wg...@fh-landshut.de> wrote:

> 
> Hello,
> 
> is it possible to convert a String to a Number?
> 
> something like this:
> #set($tmpStr = "14")
> #set($tmpInt = parseInt($tmpStr))
> 
> best regards


********************************************************************************   
DISCLAIMER: This e-mail is confidential and should not be used by anyone who is
not the original intended recipient. If you have received this e-mail in error
please inform the sender and delete it from your mailbox or any other storage
mechanism. Neither Macmillan Publishers Limited nor any of its agents accept
liability for any statements made which are clearly the sender's own and not
expressly made on behalf of Macmillan Publishers Limited or one of its agents.
Please note that neither Macmillan Publishers Limited nor any of its agents
accept any responsibility for viruses that may be contained in this e-mail or
its attachments and it is your responsibility to scan the e-mail and 
attachments (if any). No contracts may be concluded on behalf of Macmillan 
Publishers Limited or its agents by means of e-mail communication. Macmillan 
Publishers Limited Registered in England and Wales with registered number 785998 
Registered Office Brunel Road, Houndmills, Basingstoke RG21 6XS   
********************************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org