on 12-04-2007 9:31 PM
Hi
I have a number e.g 123456 (xsd:string) and sign - or + (xsd:string) and both are concatenated and fed into UDF. I want this string to be converted into Integer. If I use the below kind of statement it is not working and throwing the below error.
int BilledAmount = Integer.parseInt(b[0]);
Exception:
RuntimeException in Message-Mapping transformation: Exception:[java.lang.NumberFormatException: For input string: "+000000000006684"]
Any guess on this issue ??
Regards
Kumar
use
int BilledAmount = Integer.parseInt(b);
Thanx
Aamir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Kumar,
The problem is , you can't convert the String to Integer if it has <b>+</b> symbol in front of it. If you have negate symbol it will work.
Follow something like below example.
http://www.flickr.com/photo_zoom.gne?id=2089259274&size=o
http://www.flickr.com/photo_zoom.gne?id=2089259270&size=o
http://www.flickr.com/photo_zoom.gne?id=2089259266&size=o
raj.
Hey buddy
>>If you have negate symbol it will work.
do you mean that if he has -000000000006684 instead of +000000000006684 then Integer.parseInt(b[0]) would work?
my thinking is that in either case b[0] would return either + or - and will throw a NaN exception.
i m not a Java Guru so i might be wrong:)
Thanx
Aamir
Hey buddy,
Hope you are doing gr8, I'm getting ready leaving this friday..:-)
Aamir b[0] doesn't correspond to the first character of the string. He has multiple input values, hence he is using Context. See my structure and UDF I mentioned above, actually the above is his requirement I believe.
Yes, If you have + symbol in front of String and if you try to conver to Integer object it will throw an exception. Coz it doesn't make sense to add + symbol at all. if you don't have any sign in front it implies it's positive, am I right? But in case of negative, you need to explicitly include - symbol in front.
This is the reason that java couldn't able to convert the string that has + symbol in front, but it can in case it has - symbol in front.
I hope it clears a bit..
raj.
I m doing great,enjoy your trip,i myself am leaving on christmas eve:)
>>b[0] doesn't correspond to the first character of the string. He has multiple input values, hence he is using Context
yeah,i didn't notice he is using context.
too bad i cant open flick here:( will check it out once i get back home
Have fun on your trip
Thanx
Aamir
>>"+000000000006684"
at 0th position you can have a + or a - sign,then why do you think parseInt(b[0]) will work?
it will definitely throw an execption coz at 0th position you have a sign(+ or -) and not any number.
what exactly is your requirement anyways?
Thanx
Aamir
Message was edited by:
Aamir Suhail
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try removing the leading zeros.
regards
Mustafa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.