A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Beginning Java
Author
numberFormat...%...?
zoster gibrilian
Greenhorn
Joined: Sep 17, 2003
Posts: 7
posted
Oct 02, 2003 21:23:00
0
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
posted
Oct 02, 2003 21:39:00
0
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
posted
Oct 02, 2003 23:09:00
0
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
posted
Oct 03, 2003 00:11:00
0
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
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter