0

Lets take following Cases

Case I:

double d = 123.994;

<fmt:formatNumber type="currency" value="${d}" maxFractionDigits="2"/>

Result: 123.99

Case II:

double d = 123.996;

<fmt:formatNumber type="currency" value="${d}" maxFractionDigits="2" />

Result: 124.00 Here expected is: 123.99

So fraction values are getting rounded. But in my case i dont want it to be rounded. How to stop automatically values getting rounded. Please help me...

Pyare
  • 671
  • 2
  • 11
  • 32
  • If you are using type="currency" you do not have to specify maxFractionDigits. – Alan Hay Dec 03 '14 at 13:54
  • yes i agree. but why it is getting rounded. I don't want to it to be rounded in fractional part. – Pyare Dec 03 '14 at 14:19
  • please see the cases carefully... – Pyare Dec 03 '14 at 14:21
  • What exactly do you expect the output to be in these 2 cases? What is the target currency of the format? – Alan Hay Dec 03 '14 at 14:37
  • you can use jstl(In JSTL and EL, there is not floor, round, or ceiling function. Here is some relatively uncomplex ways to achieve the same effect.), this post can helps you but you must modify a little; http://www.bytemycode.com/snippets/snippet/1084/ – Semih Eker Dec 03 '14 at 14:41
  • I have updated what i am expecting please check – Pyare Dec 03 '14 at 15:55
  • You appear then to be looking for a Floor function which JSTL does not have. Change to value="${d - 0.005}". http://stackoverflow.com/questions/11735545/ceiling-of-a-number-in-jstl-el – Alan Hay Dec 03 '14 at 17:57

0 Answers0