Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Output format for double values

Hi, all
I need to obtain a double value which has no exponent in an csv file. The file is from a tfileOutputdelimited. In my files I got these things : 1.0137901051E8 and I need 101379010.51.
I've checked previous posts for samiliar question and found one link as below:
https://community.talend.com/t5/Design-and-Development/resolved-Suppress-Exponent-in-a-double-format...
However I'm not totally understand how to apply above solution, can we manually change the codes?
Thanks!
Labels (3)
5 Replies
Anonymous
Not applicable
Author

Hi
You can type these codes in tJava or tJavaRow.
double d = 1.0137901051E8;
java.text.DecimalFormat df = new java.text.DecimalFormat("#.##");
String s=df.format(d);
System.out.println("d = " + s);

Regards,
Pedro
Anonymous
Not applicable
Author

Hi, I append below codes into a tJavaRow component:
java.text.DecimalFormat df = new java.text.DecimalFormat("#.##");
output_row.TDCash = df.format(input_row.TDCash);
output_row.SDCash = df.format(input_row.SDCash);
output_row.Adjust = df.format(input_row.Adjust);
However when running, I got below errors:
Exception in component tJavaRow_1
java.lang.IllegalArgumentException: Cannot format given Object as a Number
at java.text.DecimalFormat.format(Unknown Source)
at java.text.Format.format(Unknown Source)
at talenddemosjava.poms_cash_adjust_0_1.POMS_Cash_Adjust.tFileInputDelimited_1Process(POMS_Cash_Adjust.java:2392)
at talenddemosjava.poms_cash_adjust_0_1.POMS_Cash_Adjust.runJobInTOS(POMS_Cash_Adjust.java:3917)
at talenddemosjava.poms_cash_adjust_0_1.POMS_Cash_Adjust.main(POMS_Cash_Adjust.java:3785)
It seems java met a type mismatch error. Can u help to have a look?
Anonymous
Not applicable
Author

Or I'm not sure how to use tJava or tJavaRow component, can anybody give an example?
Anonymous
Not applicable
Author

Hi
input_row.TDCash, input_row.SDCash and input_row.Adjust should be double/Double data type.
The output columns should be String.
Regards,
Pedro
Anonymous
Not applicable
Author

I found the problem. It's also a NULL pointer problem. After I made changes as below, the problem is resolved:
if (input_row.Adjust != null)
{output_row.Adjust = df.format(input_row.Adjust);}
Thanks!