Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Tasfiahm
Creator
Creator

Double to String Parse not working properly

Hi I am Trying to  Convert double type data to string value. When I am converting it I am getting exponential values instead of proper conversion

 

Conversion syntax: String.valueOf(row1.PI) 

 

Input Schema setup 

0683p000009M6v0.jpg

 

Output:

0683p000009M6Tt.jpg

 

JOB view:

0683p000009M77P.jpg

 

Tmap: 0683p000009M77U.jpg

Labels (2)
1 Solution

Accepted Solutions
JR1
Creator III
Creator III

This is working properly as this is standard Java behaviour. tConvertType will get you the same results. You can use the String.format method instead of String.valueOf.

String.format(row1.PI, "%.0f")

will get you an "integer" and

String.format(row1.PI, "%.2f")

will get you a number with two decimal places.

View solution in original post

6 Replies
manodwhb
Creator III
Creator III

@Tasfiahm ,can try to use tConverttype component and see are you getting the same way?

 

to know more about tConvertype.

https://help.talend.com/reader/NNO~fmVQU4rlkF9Depfdxw/w2XbvHmfgPaJT9EWmkis7w

JR1
Creator III
Creator III

This is working properly as this is standard Java behaviour. tConvertType will get you the same results. You can use the String.format method instead of String.valueOf.

String.format(row1.PI, "%.0f")

will get you an "integer" and

String.format(row1.PI, "%.2f")

will get you a number with two decimal places.

Tasfiahm
Creator
Creator
Author

Thanks for the advice. Earlier I have tried tConvertype but it was also giving me exponential values.
Tasfiahm
Creator
Creator
Author

I have used the 

String.format(row1.PI, "%.0f")

source data type: double

Target data type: String

my expression: Relational.ISNULL(row1.PI)? "" :
String.format(row1.PI, "%.0f") 

expression but I am getting the below error message:

 

execution failed : Job compile errors
At least job "t343423423R" has a compile errors, please fix and export again.
Error Line: 8822
Detail Message: The method format(String, Object...) in the type String is not applicable for the arguments (double, String)
There may be some other errors caused by JVM compatibility. Make sure your JVM setup is similar to the studio.

Tasfiahm
Creator
Creator
Author

Hi Jr,

I am not sure why your code

String.format(row1.PI, "%.0f")

in not working  but I just find the solution by changing the formation of the code.

New working code:

String.format ("%.0f", row1.PI).

 

Thanks a lot for showing the path.

 

JR1
Creator III
Creator III

Yes, sorry. It was the other way around.