简体   繁体   中英

How to format a number with XPath in Tibco BW 5

I've managed to format the following lines in XPath, from this format:

1000.50
30

to this:

100050
3000

The solution I've adopted is:

concat(substring-before([number], '.'), substring-after([number], '.'))

If the . is not present I directly multiply the number by 100.

I'm wondering if there is any better way to do that. My second thought was using Java.

What goes wrong if you just multiply by 100? So long as the result of multiplying by 100 is an exact integer, it should be formatted without a "." when converted to a string. If there are rounding errors that mean the result is not an exact integer, you might want to use round().

The concat() approach seems fragile to me: what if someone gives you input like 1000.5 or perhaps 1000.500?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM