How should I assign the fractional part to a BigDecimal that comes from a tFileInputPositional in Talend?

How should I assign the fractional part to a BigDecimal that comes from a tFileInputPositional in Talend?

 

I’m working with Talend Open Studio for Data Integration.

I’ve got a tFileInputPositional which creates several fields. One of them would look like this: “+0000030139808303”.

I need to save those fields into a BigDecimal(20,2) so that the last two digits would be the fractional part but, when typing it in the component’s schema, it simply adds “,00” at the end of the number.

So, summing up…
What I have:
+0000030139808303

What I want:
301398083,03

What I get:
30139808303,00

Could anyone help me to make it work?
Thanks!

 

Best answer

I suspect you just want BigDecimal.movePointLeft.

Returns a BigDecimal which is equivalent to this one with the decimal point moved n places to the left. If n is non-negative, the call merely adds n to the scale. If n is negative, the call is equivalent to movePointRight(-n). The BigDecimal returned by this call has value (this × 10^-n) and scale max(this.scale()+n, 0).

For example:

 

            
         

                    
                    

Leave a Reply