Is there a simple way in Java to format a decimal, float, double, etc to ONLY print the decimal portion of the number? I do not need the integer portion, even/especially if
Divide by 1 and get remainder to get decimal portion (using "%"). Use DecimalFormat to format result (using "#" symbol to suppress leading 0s):
double d1 = 67.22; double d2 = d1%1; DecimalFormat df = new DecimalFormat("#.00"); System.out.println(df.format(d2));
this prints .22