Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: Dollar Formatting


Message #1 by "Gil Barden" <gil@s...> on Sun, 25 Feb 2001 08:40:41 -0800
You can use java number format for currency:
------------------------------------------------------------
<%@ page import = "java.text.NumberFormat" %>

    <%
           NumberFormat nf =  NumberFormat.getCurrencyInstance();

          int price = 20; // get your price

   %>

 Price = <%=nf.format(price)%>

---------------------------------------------------------

----- Original Message -----
From: Gil Barden <gil@s...>
To: Pro_JavaServer_Pages <pro_jsp@p...>
Sent: Sunday, February 25, 2001 8:40 AM
Subject: [pro_jsp] Dollar Formatting


> The following will output 11.0
>
> <%
> double Price = Double.valueOf(Sale_Price).doubleValue();
> %>
>
> I know I can do this several different ways, but I was kind of wondering
on
> the best way to implement it to a dollar format of 11.00?
>
> I realize I could create my own method from a custom class, but am really
> wondering what the fastest and most common method is.
>
>
>
> Best Regards,
>
> Gil Barden


  Return to Index