wood burning stoves*
The moose likes Beginning Java and the fly likes numberFormat...%...? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "numberFormat...%...?" Watch "numberFormat...%...?" New topic
Author

numberFormat...%...?

zoster gibrilian
Greenhorn

Joined: Sep 17, 2003
Posts: 7
what method can i use to format .07 into 7%
i have found in the java API the following method:
getPercentInstance

how can i use it?
please give me an example...
bini libu
Greenhorn

Joined: Sep 18, 2003
Posts: 2
Hi zoster,
Try this...
NumberFormat nf = NumberFormat.getPercentInstance();
System.out.println(nf.format(.07));
regards
BiniLibu
zoster gibrilian
Greenhorn

Joined: Sep 17, 2003
Posts: 7
thank you...
but now i have another problem
if i input 1.9% it outputs 2%
i need 1.9% for my program...
maybe you can help me with this too...
bini libu
Greenhorn

Joined: Sep 18, 2003
Posts: 2
Hi
Try...
nf.setMinimumFractionDigits(1);
Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: numberFormat...%...?