
Anonymous
Not applicable
2008-05-28
11:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Convert string to integer or float
Hi,
Do you Know an instruction to transform a string to an integer or a float in Tmap?
Thanks
2,330 Views
23 Replies

Anonymous
Not applicable
2010-01-20
06:38 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have a problem... try to convert string to int like this "5 600" from xls file. shows error
xception in component tMap_1
java.lang.NumberFormatException: For input string: "5 250"
at java.lang.NumberFormatException.forInputString(Unknown Source)
try to do like this
row1.Hotel_commissions.toString().equals("#") || row1.Hotel_commissions.toString().equals("") ? null :
Integer.parseInt(row1.Hotel_commissions.toString().replace(" ",""))
this not help
xception in component tMap_1
java.lang.NumberFormatException: For input string: "5 250"
at java.lang.NumberFormatException.forInputString(Unknown Source)
try to do like this
row1.Hotel_commissions.toString().equals("#") || row1.Hotel_commissions.toString().equals("") ? null :
Integer.parseInt(row1.Hotel_commissions.toString().replace(" ",""))
this not help
657 Views

Anonymous
Not applicable
2010-01-21
06:53 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ug. Java's not the best for string manipulation. in perl the correct solution would be:
my $input = "5 250"
my $output = do { $input =~ s/\s//g; };
I highly suggest checking out the Perl version of Talend. Perl was built for ETL and Talend makes writing powerful ETL scripts very fast.
my $input = "5 250"
my $output = do { $input =~ s/\s//g; };
I highly suggest checking out the Perl version of Talend. Perl was built for ETL and Talend makes writing powerful ETL scripts very fast.
657 Views

Anonymous
Not applicable
2010-01-22
08:29 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
this is right if you want to drop.
Right conversion is made with Math.rint() or Math.round().or you can do it by hand:
float f = 234.33;
int i = (int)(f + 0.5f);
i has value 234
float f = 234.57;
int i = (int)(f + 0.5f);
i has value 235;
Right conversion is made with Math.rint() or Math.round().or you can do it by hand:
float f = 234.33;
int i = (int)(f + 0.5f);
i has value 234
float f = 234.57;
int i = (int)(f + 0.5f);
i has value 235;
657 Views

Contributor
2012-02-29
10:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I want to parse a string and change the format as given below,
Input : C0003129872
Outpput : C=3129872
Could anyone tell me how can this be obtained pls?
I want to parse a string and change the format as given below,
Input : C0003129872
Outpput : C=3129872
Could anyone tell me how can this be obtained pls?
657 Views

Anonymous
Not applicable
2012-03-01
03:42 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi baskarchennai,
You can do it by using this code:
Regards,
Khor.
You can do it by using this code:
StringHandling.CHANGE("C0003129872", "000", "=")
Regards,
Khor.
659 Views

Contributor
2013-08-12
09:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I would like to know how I do in Talend to calculate the age of a person from his date of birth?
I know we need to use the current date, but I look for the syntax.
Thank you in advance
I would like to know how I do in Talend to calculate the age of a person from his date of birth?
I know we need to use the current date, but I look for the syntax.
Thank you in advance
659 Views

Specialist
2013-08-12
10:52 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Don't post the same question more than once -
https://community.talend.com/t5/Design-and-Development/Calculate-the-age-from-the-current-date-and-t....
659 Views

Specialist III
2015-06-02
03:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
More about......String to Integer
Biden
Biden
659 Views

Contributor
2018-05-01
06:12 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i want to convert from float to double. i used this, "row1.doubleValue() " . now i'm facing null point exception error. Any suggestions.
659 Views

Champion II
2018-05-02
01:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@nareshm, you are getting null as part of data,so before converting to double handle nulls like this .
row1.Value==null ? row1.Value.doubleValue() : row1.Value
659 Views
