import java.math.BigDecimal; public class Main { public static void main(String[] argv) throws Exception { int decimalPlaces = 2; BigDecimal bd = new BigDecimal("123456789.0123456890"); bd = bd.setScale(decimalPlaces, BigDecimal.ROUND_DOWN); String string = bd.toString(); } }