cancel
Showing results for 
Search instead for 
Did you mean: 

Convert xsd:double to xsd:decimal

Former Member
0 Kudos

Hi,

I have an incoming field which is xsd:double and I need to convert the field into xsd:decimal

For example:

Incoming field - 5.13964E11

Outgoing field - 513964000.00

Any ideas how to do this ??

Thanks

Colin.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Not required

Former Member
0 Kudos

Collin,

Use this UDF. I guess this will work for large values too

<b>BigDecimal bd = new BigDecimal(String a);

return bd.toString();</b>

Regards,

Jai Shankar

Former Member
0 Kudos

Colin,

U can use a small UDF.

double input = Double.parseDouble(a);

return (long)input;

Regards,

Jai Shankar

stefan_grube
Active Contributor
0 Kudos

Hi Jay,

In a UDF you have to work with strings, so you cannot return a long type.

Stefan

Former Member
0 Kudos

Stefan,

Oops!! Sorry for that. Replace this

return (long)input;

by

return ((long)input.toString();

P.S: How ever, I am not so sure if this code can handle very large double values. I guess you need to go for BigInteger or BigDecimal.

Regards,

Jai Shankar

Former Member
0 Kudos

Hi Colin,

you can create a target data type in which you can take outgoing field as string variable.....

then in msg mapping, make a small UDF in JAVA.......take your input field to it....

in UDF, cast the input to double..........then convert it to decimal.....then cast it back to string.......then output this string.......

then take output of UDF to target........so you will get outgoing field in decimal format as string............

Then you can process your target XML in your target system.

Thanks,

Rajeev Gupta

Message was edited by:

RAJEEV GUPTA