Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

number format

 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to format a number in terms of dollars and cents inside my jsp code, so without using jstl libraries. Can someone please tell me how I can do this, maybe post an example?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by liliya woland:
without using jstl libraries.


Why not?

Can someone please tell me how I can do this, maybe post an example?


Explore java.text.NumberFormat
 
Rusty Smythe
Ranch Hand
Posts: 93
Mac Objective C Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a standalone app I whipped out for you:



Just steal the guts and have fun.
 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because I'm concatinating my numbers into a String in one case and adding them up as an Integer into a sum in another case before they the numbers go into a web page. At this point I'm using
NumberFormat numformat = NumberFormat.getInstance();
It works fine when I do numformat.format(somenum)
 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Rusty!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic