#1 2009-06-08 15:09:33

Jose Vaquero
Guest

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

#2 2009-06-08 19:55:41

bcourtine
Member
Company: Alcion Group
Registered: 1970-01-01
Posts: 64
Website

Re: Format of decimal number

With java jobs, you can use the java class "DecimalFormat" in a tJavaRow :

Code:

DecimalFormat myFormat = new DecimalFormat("0.00");
rowX.myFormattedDate = myFormat.format(rowX.myNumericRow);

Java/J2EE and Talend certified consultant for Alcion Group.

Offline

#3 2009-06-12 10:21:08

Jose F Vaquero
Guest

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

#4 2009-06-12 10:40:03

shong
Talend team
Registered: 2007-08-29
Posts: 10310
Website

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


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#5 2009-06-17 13:49:49

Jose Vaquero
Guest

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

#6 2009-06-17 14:45:20

emenuet
Talend team
Registered: 2008-04-17
Posts: 144
Website

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"

Offline

Board footer

Powered by FluxBB