Transform a BigDecimal

Five Stars

Transform a BigDecimal

Hi,

I want to transform a BigDecimal, like this -.22 that I read with a tFileDelimited component, in a BigDecimal like this -0.22, so i want to add a zero between the "-" and ".".

I tried to use the function add() but it always gives me an exception.

There is some other function in the tMap that allows me to do this transformation or another method i can use?

Thanks 


Accepted Solutions
Sixteen Stars

Re: Transform a BigDecimal

You do not need to do this.  The BigDecimal is a number class. It will hold the number as a number and format really does not matter. In fact, if you specify your BigDecimal in a tJava as below.....

 

String stringBd = "-.22";

BigDecimal bd = new BigDecimal(stringBd);

System.out.println(bd.toPlainString());

.....it will print out "-0.22".


All Replies
Sixteen Stars

Re: Transform a BigDecimal

You do not need to do this.  The BigDecimal is a number class. It will hold the number as a number and format really does not matter. In fact, if you specify your BigDecimal in a tJava as below.....

 

String stringBd = "-.22";

BigDecimal bd = new BigDecimal(stringBd);

System.out.println(bd.toPlainString());

.....it will print out "-0.22".