Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Creator III
Creator III

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?
Labels (3)
4 Replies
Anonymous
Not applicable

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

Best regards
Sabrina
djugal
Contributor III
Contributor III

just use tconverttype for all the conversions its very useful
Thanks & Regards,
djugal
Anonymous
Not applicable

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.
alevy
Creator III
Creator III

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)