Copy the code code as follows:
import java.text.* ;
import java.math.* ;
public class Test
{
public Test(){
double a=saveNumber(15.12312312,6);
System.out.println("a...."+a);
}
//Keep the number of decimal places
//number is the number to be processed, digit is the number of digits to be retained
public double saveNumber(double number,int digit){
NumberFormat ddf1=NumberFormat.getNumberInstance();
ddf1.setMaximumFractionDigits(digit);
String s= ddf1.format(number);
double Num=Double.parseDouble(s);
return Num;
}
public static void main(String args[])
{
new Test();
}
}