Highlighted
Five Stars

[resolved] how convert string "1234567" to "12345.67" using expresstion builder

Hi all
i am getting input in string format which is plane integer and want to convert it to decimal format. as the subject line eg. shows if my input string is "1234567" then want to out put it in 12345.67. please suggest.
1 ACCEPTED SOLUTION

Accepted Solutions
Five Stars

Re: [resolved] how convert string "1234567" to "12345.67" using expresstion builder

new BigDecimal(Numeric.convertImpliedDecimalFormat("9V99","123456"));
this works for me
10 REPLIES
Five Stars

Re: [resolved] how convert string "1234567" to "12345.67" using expresstion builder

new BigDecimal(Numeric.convertImpliedDecimalFormat("9V99","123456"));
this works for me
One Star

Re: [resolved] how convert string "1234567" to "12345.67" using expresstion builder

Hi
Glad that you find the answer.
Seasons Greeting!
Best regards!
Pedro
One Star

Re: [resolved] how convert string "1234567" to "12345.67" using expresstion builder

Hi new BigDecimal(Numeric.convertImpliedDecimalFormat("9V99","123456")); is not working in my case.Is there any other alternative available to do the same?
Five Stars

Re: [resolved] how convert string "1234567" to "12345.67" using expresstion builder

Hi Nikhil,
yes i agree that some time it is not working,i don`t know but you can wright routines to done this task. create a one routine and wright down below code. and let me know if it is working for you or not.
// pass your column name to this function.
public static String ChangeToDecimal(String message) {
{

if(message.length()>2)
{
temp=message.substring(0,message.length()-2) +"."+message.substring(message.length()-2);

}
else
{
temp="0.00";
}
}
return temp;
}
One Star

Re: [resolved] how convert string "1234567" to "12345.67" using expresstion builder

Hey Umesh Thank you!! Now its working!!Thank you for your suggestion!!!
One Star

Re: [resolved] how convert string "1234567" to "12345.67" using expresstion builder

If your output field is decimal with 2 places why not just divide by 100?
Five Stars

Re: [resolved] how convert string "1234567" to "12345.67" using expresstion builder

Hi Janhess thank you for sharing easy way of convert into decimal.
One Star

Re: [resolved] how convert string "1234567" to "12345.67" using expresstion builder

Hello,
Is someone can help me about the routine,i'm a bit confused?
you said:
// pass your column name to this function
Where must i put in the function my column name?(column name is VAL_DEC
Then,
how can i use this routine in a tmap please?
thanks a lot
Four Stars

Re: [resolved] how convert string "1234567" to "12345.67" using expresstion builder

HI stephane.michemiche

Use routine as keyword, it will display all your defined routines as well as the class which you defining should contain be a static method in java it comes by default when you create a routine dont change any class defination while writing you routine class as well as static method defination
ex:
public class RoutineName
{
public static returnType methodName(arg1, arg2...)
{
---------------
bussiness logic..
---------------
return returnType;
}
}
thanks
Anil Kumar Burri
http://anilkumarburri.wordpress.com/
Moderator

Re: [resolved] how convert string "1234567" to "12345.67" using expresstion builder

Hi stephane.michemiche,
Here is a KB article about Creating a user routine and call it, hope it will be helpful for you.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.