You might consider using the NumberFormat class. It lets you format
numbers based on the default locale (or a specified locale):

NumberFormat fmt = NumberFormat.getNumberInstance();
fmt.setMaximumFractionDigits(2);
fmt.setMinimumFractionDigits(2);
String numstr = fmt.format(yournumber);

If you're printing currency, try:
NumberFormat fmt = NumberFormat.getCurrencyInstance();
String numstr = fmt.format(yournumber);

   Mark

> ------Original Message------
> From: "Jay H. Lang" <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Sent: December 8, 2000 2:05:20 PM GMT
> Subject: Display of money
>
>
> Hi All,
> I am using a float variable in a JSP to total some values.  Once totaled
> I use the variable on the out display.  When I have two non-zero values
> to the right of the decimal it shows fine, i.e 1.53.  When my last digit
> is a zero it shows, 1.5, leaving off the trailing zero.  I have looked
> and can't seem to find an Object or variable type I can convert this to,
> just prior to its display to get the trailing zero to print.
>
> Thanks for any help given.
> --
> Jay H. Lang
> Chief Technologist
> Distributed Computing Professionals Inc.
> IBM Certified Specialist - MQSeries
> 303 277-1873 - Office
> 303 807-9700 - Cell
>

--

Mark Wutka
Author of Special Edition Using Java Server Pages & Servlets (ISBN: 0789724413)

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to