aspose file tools
The moose likes Beginning Java and the fly likes numberFormat...%...? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply 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://jrebel.com/download
 
subject: numberFormat...%...?
 
Similar Threads
How do I call method of jsp from servlets?
The method setAlt(String) in the type BaseHandlerTag is not applicable for the arguments (int)
a question about polymorphism ??
frame properties
JSP FAQ