Try this. I hope it handles all your requirements.

public static void main(String[] args) {
    double d = 20.0;
    int decimalPlaces = getDecimalPlaces(d) - 1;
    double res = Math.round(d * Math.pow(10, decimalPlaces))/Math.pow(10, decimalPlaces); // Rounding
    String text = Double.toString(Math.abs(res));
    int integerPlaces = text.indexOf('.');
    if (getDecimalPlaces(res) == 1 &amp;&amp; text.charAt(integerPlaces + 1) == '0') 
        System.out.println((int)res);
    else
        System.out.println(res);
}

private static int getDecimalPlaces(double d) {
    String text = Double.toString(Math.abs(d));
    int integerPlaces = text.indexOf('.');
    int decimalPlaces = text.length() - integerPlaces - 1; // To Round
    return decimalPlaces;
}


How to remove the “ .0” in Decimal format and convert 1.01 to 1 in java
I'm writing a scene exporter from blender to a format to be used by a game. I need to be able to export physics information the game needs, mainly the collision shape of every object (either the one set in Blender Render or Blender Game but the latter is better).

I cannot seem to find anywhere that the collision shape is available to python. I've seen references to PhysicsConstraints.exportBulletFile() but this appears to be under the bge module, which as far as I can tell, is not accessible by exporter scripts. Is there any way to determine the details of a shape (rotation and scale, width, height, depth for box or radius and height for cylinder, vertices for convex hull, etc...)?
