I think that the RoundingMode you are looking for is HALF_EVEN. From the javadoc:

Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor. Behaves as for ROUND_HALF_UP if the digit to the left of the discarded fraction is odd; behaves as for ROUND_HALF_DOWN if it's even. Note that this is the rounding mode that minimizes cumulative error when applied repeatedly over a sequence of calculations.

Here is a quick test case:

BigDecimal a = new BigDecimal("10.12345");
BigDecimal b = new BigDecimal("10.12556");

a = a.setScale(2, RoundingMode.HALF_EVEN);
b = b.setScale(2, RoundingMode.HALF_EVEN);

System.out.println(a);
System.out.println(b);

Correctly prints:

10.12
10.13

UPDATE:

setScale(int, int) has not been recommended since Java 1.5, when enums were first introduced, and was finally deprecated in Java 9. You should now use setScale(int, RoundingMode) e.g:

setScale(2, RoundingMode.HALF_EVEN)

Answer from Florent Bayle on Stack Overflow
🌐
Sentry
sentry.io › sentry answers › java › round a number to n decimal places in java
Round a Number to N Decimal Places in Java | Sentry
The precision offered by the BigDecimal class makes this approach suitable for financial and high-precision applications. You can use the Java DecimalFormat class to define a format pattern that rounds numbers to a specific number of decimal places for display. The following example creates a DecimalFormat object with the format pattern #.## (where # represents digits) to round the number to 2 decimal places:
🌐
John Dalesandro
johndalesandro.com › blog › rounding-decimals-in-java-avoiding-round-off-errors-with-bigdecimal
Rounding Decimals in Java: Avoiding Round-Off Errors with BigDecimal
March 21, 2025 - Method 4: Rounded using BigDecimal Input value: 3.14159265358979323846264338327950288419716939937510 -------- Rounded to 0 decimal places: 3 Rounded to 1 decimal places: 3.1 Rounded to 2 decimal places: 3.14 Rounded to 3 decimal places: 3.142 ...
🌐
BeginnersBook -
beginnersbook.com › home › java › how to round a number to two decimal places in java
How to round a number to two decimal places in Java
May 31, 2024 - In this approach, there are two ... = new BigDecimal(Float.toString(floatValue)); First step is to convert the given double and float values to BigDecimal. This can be done using Double.toString() method....
🌐
TutorialsPoint
tutorialspoint.com › set-decimal-place-of-a-big-decimal-value-in-java
Set Decimal Place of a Big Decimal Value in Java
To set decimal place of a BigDecimal value in Java, try the following code − · Live Demo · import java.math.BigDecimal; public class Demo { public static void main(String[] argv) throws Exception { int decPlaces1 = 3; int decPlaces2 = 5; BigDecimal val1 = new BigDecimal("37578975587.876876989"); BigDecimal val2 = new BigDecimal("62567875598.976876569"); System.out.println("Value 1 : "+val1); System.out.println("Value 2 : "+val2); // ROUND_DOWN val1 = val1.setScale(decPlaces1, BigDecimal.ROUND_DOWN); String str1 = val1.toString(); System.out.println("Result = "+str1); // ROUND_UP val2 = val2.setScale(decPlaces2, BigDecimal.ROUND_UP); String str2 = val2.toString(); System.out.println("Result = "+str2); } } Value 1 : 37578975587.876876989 Value 2 : 62567875598.976876569 Result = 37578975587.876 Result = 62567875598.97688 ·
🌐
Oreate AI
oreateai.com › blog › how-to-format-bigdecimal-to-2-decimal-places › c0faf7bf2d3e9fdc00fcacc804ed8d6b
How to Format Bigdecimal to 2 Decimal Places - Oreate AI Blog
January 7, 2026 - Setting Scale: Next up is setting the scale (the number of digits after the decimal point). We use setScale(2) which tells our program we want exactly two digits after the dot—and we specify rounding mode with ROUND_HALF_UP.
Find elsewhere
🌐
How to do in Java
howtodoinjava.com › home › java basics › round off a float number to 2 decimals in java
Round Off a Float Number to 2 Decimals in Java
February 16, 2024 - Note that we can use the given ... = Math.round(number * 100.0) / 100.0; // 4.57 // 2. Using BigDecimal BigDecimal rounded = new BigDecimal(number).setScale(2, RoundingMode.HALF_UP); // 4.57 // 3....
🌐
Mkyong
mkyong.com › home › java › java – display double in 2 decimal places
Java - Display double in 2 decimal places - Mkyong.com
October 29, 2021 - In Java, we can use DecimalFormat("0.00"), String.format("%.2f") or BigDecimal to display double in 2 decimal places.
🌐
Jaspersoft Community
community.jaspersoft.com › knowledge base › how-to
How to round up BigDecimal value - How-To - Jaspersoft Community
November 2, 2018 - I want to round up the value to 2 decimal place like 8.23. You should design Java expression that performs the desired type of rounding. I have created a sample of the report that uses dummy sql and could be checked with any JDBC data source (I checked this report with PostgreSQL JDBC data source). To implement the desired solution in the report is used expression below: new BigDecimal($F{one}).setScale(2, BigDecimal.ROUND_CEILING)
🌐
Qlik Community
community.qlik.com › t5 › Talend-Studio › resolved-How-to-make-float-round-to-2-decimal-places-in-tMap › td-p › 2350563
[resolved] How to make float round to 2 decimal places in tMap?
August 23, 2023 - BigDecimal bd = new BigDecimal(2.437732); BigDecimal bd2 = bd.setScale(2,BigDecimal.ROUND_HALF_UP); System.out.println("bd2 = "+bd2); and it outputs: Starting job test at 17:13 22/05/2014. connecting to socket on port 3511 connected bd2 = 2.44 ...
🌐
Baeldung
baeldung.com › home › java › java numbers › how to round a number to n decimal places in java
How to Round a Number to N Decimal Places in Java | Baeldung
September 24, 2025 - In this quick tutorial, we’ll ... decimal places in Java. Java provides two primitive types that we can use for storing decimal numbers: float and double. Double is the default type: ... However, we should never use either type for precise values like currencies. For that, and also for rounding, we can use the BigDecimal ...
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › math › BigDecimal.html
BigDecimal (Java Platform SE 8 )
October 20, 2025 - Scaling/rounding operations (setScale and round) return a BigDecimal whose value is approximately (or exactly) equal to that of the operand, but whose scale or precision is the specified value; that is, they increase or decrease the precision of the stored number with minimal effect on its value. Decimal point motion operations (movePointLeft and movePointRight) return a BigDecimal created from the operand by moving the decimal point a specified distance in the specified direction.
🌐
Tutorialspoint
tutorialspoint.com › home › java/math › bigdecimal round in java
BigDecimal Round in Java
September 1, 2008 - The following example shows the usage of math.BigDecimal.round() method. package com.tutorialspoint; import java.math.*; public class BigDecimalDemo { public static void main(String[] args) { // create 2 BigDecimal Objects BigDecimal bg1, bg2; ...
🌐
Coderanch
coderanch.com › t › 744280 › java › double-decimal-places-Java
Trying to round up double for two decimal places using Java 1.8? (Java in General forum at Coderanch)
That method is subject to the usual ... datatype (approx. 15.9 decimal digits), the rounding will have no visible effect. Yes, you can use a BigDecimal and round with the CEILING rounding mode....
🌐
Medium
medium.com › @omernaci › using-bigdecimal-in-java-avoiding-common-pitfalls-and-best-practices-99ad61364eb2
Using BigDecimal in Java: Avoiding Common Pitfalls and Best Practices | by Ömer Naci Soydemir | Medium
November 9, 2024 - When creating a new BigDecimal object, it is recommended to use the String constructor instead of the double constructor. This is because the double constructor can introduce rounding errors due to the way double values are represented in binary format. By using the String constructor, you can ensure that the decimal value is represented accurately.
🌐
GeeksforGeeks
geeksforgeeks.org › java › bigdecimal-round-method-in-java
BigDecimal round() Method in Java - GeeksforGeeks
December 4, 2018 - Below programs illustrate the working ... MathContext m = new MathContext(4); // 4 precision // b1 is rounded using m BigDecimal b2 = b1.round(m); // Print b2 value System.out.println("The value of " + b1 + " after rounding is " + ...