• Post Reply Bookmark Topic Watch Topic
  • New Topic

number format  RSS feed

 
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?
 
Author and ninkuma
Marshal
Posts: 66676
167
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
 
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!
 
You can thank my dental hygienist for my untimely aliveness. So tiny:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!