The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

use NumberFormat

Posted by babuReddy on January 19, 2001 at 12:06 AM

java.text.NumberFormat nm = java.text.NumberFormat.getInstance(java.util.Locale.US);
nm.setMaximumFractionDigits(2);

you can use Minimumfraction option
nm.setMinimumFractionDigits(2);
and also Grouping option ie
nm.setGroupingUsed(true);
nm.format(anyNumber);
this will display a number like
12,123,239.12

with out grouping

it will display
12123239.12



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us