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

Highlighted
Six 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.

Accepted Solutions
Highlighted
Six Stars

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

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

View solution in original post


All Replies
Highlighted
Six Stars

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

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

View solution in original post

Highlighted
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
Highlighted
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?
Highlighted
Six 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;
}
Highlighted
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!!!
Highlighted
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?
Highlighted
Six 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.
Highlighted
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
Highlighted
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/
Highlighted
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.

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog