Format of decimal number

One Star

Format of decimal number

Hello:
I need convert some numbers, from a BD in format double, to a XML file. I need than the number has two decimals. How can I do, when the original number is 0? I only get the result 0.0, but I need 0.00
Another example of the same problem: when I pass the number 8.36 to SML, I need six decimals, and so I need 8.360000
Greetings Thanks
Jose
One Star

Re: Format of decimal number

With java jobs, you can use the java class "DecimalFormat" in a tJavaRow :
DecimalFormat myFormat = new DecimalFormat("0.00");
rowX.myFormattedDate = myFormat.format(rowX.myNumericRow);
One Star

Re: Format of decimal number

Thank you for the answer, but...
I need put this code in the "expression Builder", in a component tMap. In this place, it don't work,it say "syntax error". I think than I could use a direct function to became the result. Some idea??
Greetings
Community Manager

Re: Format of decimal number

Hello
in a component tMap. In this place, it don't work,it say "syntax error"

Write these code in a routine, then call the routine on tMap.
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Format of decimal number

Thank you for the answer.
If I wat to use a conditional sentence, can I used some function in a tMap, or I must add this conditional sentence in a routine too?
I think, for example:
if field1 == Y
"ELECTRONIC"
else
POSTAL
Greetings
Employee

Re: Format of decimal number

hello,
you can use this in a tMap expression field :
1) Y, POSTAL and field1 are var : field1 == Y ? "ELECTRONIC" : POSTAL
2) Y, POSTAL are String : "Y".equals(field1) ? "ELECTRONIC" : "POSTAL"