Lee Chin Khiong wrote:
How to format a double in JSP or java ?
for example :
10/3=3.3
I want to format it to 3.33.
Try realToString(3.33, 2) with this:
/** Convert a float to a string with fixed number of fraction digits
*/
public static String
There are some non-standard nice library classes you can use for this purpose. Just
google it. These classes enable you to format things like you are working with c/c++.
Lee Chin Khiong [EMAIL PROTECTED] wrote:
How to format a double in JSP or java ?
for example :
10/3=3.3
I
Users List [EMAIL PROTECTED]
|
| cc:
|
| Subject: Re: How to format number
PROTECTED]
Sent: Tuesday, October 07, 2003 11:44 AM
To: Tomcat Users List
Subject: Re: How to format number
There are some non-standard nice library classes you can use for this
purpose. Just google it. These classes enable you to format things like
you are working with c/c++.
Lee Chin Khiong
In JSP, the easiest is to use the formatNumber tag of the JSTL I18N library. For
example, the following JSP page:
lt;%@ taglib uri=quot;http://java.sun.com/jsp/jstl/fmtquot; prefix=quot;fmtquot;
%gt;
lt;fmt:formatNumber value=quot;0.3quot; maxFractionDigits=quot;2quot;/gt;
lt;br/gt;
Look into the java.text package, you'll find a Number formatter there.. or
if you dont want a String, use Math.round()
- Original Message -
From: Lee Chin Khiong [EMAIL PROTECTED]
To: 'Tomcat Users List' [EMAIL PROTECTED]
Sent: Monday, October 06, 2003 6:37 PM
Subject: How to format