This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NumberFormat API question

 
pjoisha
Ranch Hand
Posts: 124
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I ran into a problem with the NumberFormat
class and I was wondering if someone had
a solution. Basically, if I run the
following snippet
NumberFormat format = NumberFormat.getInstance();
format.setMaximumFractionDigits(2);
format.setGroupingUsed(false);
System.out.println(format.format(5.795));
I get 5.8. However, what I really expected to see
was 5.80. Does anyone know of a nice workaround to
fix this problem?
TIA,
PJ
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<pre> format.setMinimumFractionDigits(2);</pre>
 
pjoisha
Ranch Hand
Posts: 124
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jim ... PJ
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic