wood burning stoves 2.0*
The moose likes JSP and the fly likes formatting amounts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "formatting amounts" Watch "formatting amounts" New topic
Author

formatting amounts

gino mendoza
Greenhorn

Joined: Jul 12, 2002
Posts: 20
Can anyone help with formatting amounts to be displayed using JSP?
Thanks.
sunitha reghu
Ranch Hand

Joined: Dec 12, 2002
Posts: 937
DecimalFormat df = new DecimalFormat("00000000.00");
df = (DecimalFormat)NumberFormat.getInstance(Locale.US);
//Locale can be changed to ur req:
df.format(your amt)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

Your best bet is to use the fmt JSTL tags.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
Formatting is more to do with your helper functions that are available for your application rather than JSP.
You can create a amount formatter method in a singleton helper class(that has other formatting functions aswell) and access that method from JSP.
The method is obviously static.
Kishore.


Kishore
SCJP, blog
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

Why create singleton "helper" classes when a standardized, page-centric solution already exists?
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
I explained what I am using.
If you think format is the best bet(using JSTL) let it be
Kishore.
 
Consider Paul's rocket mass heater.
 
subject: formatting amounts