Double d = 3.35;
BigDecimal bd = new BigDecimal(d);
bd = bd.setScale(1, BigDecimal.ROUND_HALF_UP);//BigDecimal.ROUND_HALF_UP 是4舍5入,BigDecimal.ROUND_DOWN是舍去,BigDecimal.ROUND_FLOOR是向上取整
double b =5.1212;
DecimalFormat decimalFormat = new DecimalFormat(".#");
double c =Double.parseDouble(decimalFormat.format(b)) ;
double b =5.1212; DecimalFormat decimalFormat = new DecimalFormat(".#"); double c =Double.parseDouble(decimalFormat.format(b)) ;