Convert int to bigdecimal tMap

One Star

Convert int to bigdecimal tMap

Hi,
Im trying to calculate how large of the percentage of a month that has already gone by.
I've tried to do it like this:
java.util.Calendar.getInstance().get(java.util.Calendar.DATE) / java.util.Calendar.getInstance().getMaximum(java.util.Calendar.DAY_OF_MONTH);
The calculation seems to work, but it is type integer, so the result is wrong. How can I get it to be a decimal figure?
Moderator

Re: Convert int to bigdecimal tMap

Hi,
Could you convert int->BigDecimal using
java.math.BigDecimal()

Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: Convert int to bigdecimal tMap

just use tconverttype for all the conversions its very useful
Thanks & Regards,
djugal
Seventeen Stars

Re: Convert int to bigdecimal tMap

tconverttype is missing a lot of needed conversions. E.g. BigDecimal -> Integer or Long.
Unfortunately the BigDecimal type will be used much to often even if Integer is quite enough.
Seven Stars

Re: Convert int to bigdecimal tMap

tConvertType happily converts BigDecimal to Integer or Long but that won't solve your problem. You need to have the numerator as a non-Integer before the division so use:
((Integer)java.util.Calendar.getInstance().get(java.util.Calendar.DATE)).doubleValue() / java.util.Calendar.getInstance().getMaximum(java.util.Calendar.DAY_OF_MONTH)