Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
Output:
JOB view:
Tmap:
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 ,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
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.
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.
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.
Yes, sorry. It was the other way around.