Question

This might be kind of a dumb question, but I'm stuck on it.

I'm trying to set the RoundingMode on a DecimalFormat.

DecimalFormat df = new DecimalFormat("###.##");
df.setRoundingMode(RoundingMode.HALF_UP);

However, the code looks fine to me and it looks the same as many examples I have seen.

The error on setRoundingMode() is:

***The method setRoundingMode(RoundingMode) is undefined for the type DecimalFormat***

It suggests to cast df to an Object, but that doesn't solve anything...

Any suggestions?

EDIT

I am using ver. 1.7

Below I changed the compliance level to 1.6 yet no difference.

Java Compiler

Thank you in advance for the help!

Était-ce utile?

La solution

Try System.out.println(System.getProperty("java.version")); and be sure that your jre version really is 1.6 or higher

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top