/**
* 使用这个方法将订单金额在十位四舍五入
* 若:1568.145 装换后:1570
* 1522 转成 1520
*/
import java.math.BigDecimal; public class myround { public static void main(String[] args) { myround m = new myround(); BigDecimal num = new BigDecimal(1245656.24); Double db = num.doubleValue(); System.out.println(m.roundTen(db)); } private int roundTen(double db) { int roundedInt = (int) Math.round(db); if (roundedInt % 10 < 5) { return (roundedInt / 10) * 10; } return (roundedInt / 10) * 10 + 10; } }