I'm trying to use this code to get number 2.90
printed from the intial number 2.90689
:
double number = 2.90689;
DecimalFormat df = new DecimalFormat("#.##");
df.setRoundingMode(RoundingMode.FLOOR); //error
System.out.println(df.format(number));
However I get the Usage of API documented as @since 1.6+ error
when trying to set rounding mode. How do I solve this in a modern way? All answers I've found use this seemingly deprecated code.
PS: It's not an error, but a warning in IDE. When run, it also doesn't work properly: prints 2.9
instead of 2.90
. I've made this repl: https://repl.it/repls/IllInterestingComputers.