Rounding amounts in Germany we must use
Math.round instead of
Is there any rounding-function for amounts who accepts the Locale in Java?
This is not improbably since
toUpperCase respects the Locale too.
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.Sign up to join this community
Working at three different places in one state within the US, I've encountered three different ways of rounding numbers in different applications. This isn't locale dependent - its industry dependent (finance, retail, science all round differently for different reasons).
HALF_UP) always. Makes it consistent and easy to explain.
HALF_EVENto avoid systematic biasing of the data (half the time
x.5gets rounded up, half the time it gets rounded down - so
1.5gets rounded to
2.5also gets rounded to
2(more on this on Wikipedia which points out this is sometimes known as "bankers' rounding")).
Localeobject represents a specific geographical, political, or cultural region.
(From the javadocs for java.util.Locale)
So no. There is no local association for rounding. Not everyone in a given locale always rounds the same way. It depends on the application - not the geographical, political or cultural grouping.
"Kaufmännisches Runden" seem to just be the German name for "Bankers rounding". It is not something culture specific.
See the various rounding modes supported here: http://docs.oracle.com/javase/7/docs/api/java/math/RoundingMode.html