Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

numberFormat...%...?  RSS feed

 
zoster gibrilian
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi zoster,
Try this...
NumberFormat nf = NumberFormat.getPercentInstance();
System.out.println(nf.format(.07));
regards
BiniLibu
 
zoster gibrilian
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Try...
nf.setMinimumFractionDigits(1);
Regards
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!