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?
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.
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)