dcsimg
how to show currency -ve values
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   pat_pat
Posted On:   Friday, January 24, 2003 11:01 AM

I want to display -ve dollar Amount on my JSP page, i using like

NumberFormat nf = NumberFormat.getCurrencyInstance();

double getAccWiseTotals11 = balancereport.getAccountWiseTotals11();

<%=nf.format(getAccWiseTotals11)%>


BUT IT DISPLAY VALUE LIKE: ($120,233,456.23)ACTUAL VALUES IS

-$120,233,456.23


how to get a -ve dollar amount displayed on JSP page using
getCurrencyInstance method ?


any help greatly appreciated, Thanks in advance.

Re: how to show currency -ve values

Posted By:   Sunit_Bhargava  
Posted On:   Saturday, January 25, 2003 03:08 AM

hi
there is a tricky answer also


Try below code


<% NumberFormat nf = NumberFormat.getCurrencyInstance();

double getAccWiseTotals = -120233456.23;

double temValue = (-1) * getAccWiseTotals;

nf.setMaximumFractionDigits(2);

nf.setMinimumFractionDigits(2); %>

<% if(getAccWiseTotals < 0){%>

-<%=nf.format(temValue) %>

<%}%>

Re: how to show currency -ve values

Posted By:   Sunit_Bhargava  
Posted On:   Saturday, January 25, 2003 02:56 AM


It is mentioned in API that if any -ve value is formatted , it is shown under the parentheses. so , its giving rite value.


for ur ref: API says
If you are using proportional fonts, instead of padding with spaces, measure the width of the string in pixels from the start to getEndIndex. Then move the pen by (desiredPixelWidth - widthToAlignmentPoint) before drawing the text. It also works where there is no decimal, but possibly additional characters at the end, e.g., with parentheses in negative numbers: "(12)" for -12.

About | Sitemap | Contact