// Creating number format object to set 2 places after decimal point
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(2);
nf.setGroupingUsed(false);
System.out.println(nf.format(precision));// Assuming precision is a double type variable
In this example, decimalPlaces would be the number of places PAST the ones place you wish to go, so 1 would round to the 十分之一 place, 2 to the hundredths, and so on (0 rounds to the 一个 place, and negative one to the tens, etc.)
public boolean checkTwoDecimalPlaces(double valueToCheck) {
// Get two decimal value of input valueToCheck
double twoDecimalValue = Math.floor(valueToCheck * 100) / 100;
// Return true if the twoDecimalValue is the same as valueToCheck else return false
return twoDecimalValue == valueToCheck;
}
double a=3.545555555; // just assigning your decimal to a variable
a=a*100; // this sets a to 354.555555
a=Math.floor(a); // this sets a to 354
a=a/100; // this sets a to 3.54 and thus removing all your 5's