I need a solution to a application wide problem (gf 3x, jdk1.6). The default rounding mode is half_even in java. So the jstl and the decimalformat that are used in the web app should be changed to use half_up. Unfortunately the does not support setting rounding mode. I can define a new method for each class referenced or I can write my own custom tag library.
Which one would you recommend ? Thanks.
Unfortunately, I could not find a global system property that will let me change it across all. This could be done, at the application level to define a decimal format, that’s per thread and used accordingly by writing a filter and injecting into a request. I have not tried the approach since I did not like the idea.
Instead, I have created a separate method for each attribute that needed rounding to be done in HALF_UP. The application I work on uses jsp code as well as jstl. For jsp, it is easy enough to set the rounding mode for decimalformat. However, there is no such way for JSTL, for JSTL, I went with creating a method that did the rounding.