'Create Function class in My Routine in Talend

Anyone Can help me to fix my Java Function to use it in my Routine.

The Function will remove exponent and put it in a Float format.

This is the function :

float amount = 3.53435E12;
java.text.DecimalFormat df = new java.text.DecimalFormat("# .# ");
String s=df.format(amount );
System.out.println("amount = " + s);

it will convert the number format from this 3.53435E12 to this 3 534 350 000 000

the result will be like this ---> 3 534 350 000 000

Now i want to create a function in my Routine in order to use it in Tmap with my column.

Thanks.



Solution 1:[1]

In your routine named for Example MyRoutine

 public static double convertNumber(double message) {
    
    java.text.DecimalFormat df = new java.text.DecimalFormat("# .# ");
    String s=df.format(message );
    System.out.println("amount = " + s);
    return (Double.parseDouble(s))  ;

}

The in tMap simply call

MyRoutine.convertNumber(row1.amount)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1