aspose file tools*
The moose likes Other Open Source Projects and the fly likes how to display negative values within parenthesis? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "how to display negative values within parenthesis?" Watch "how to display negative values within parenthesis?" New topic
Author

how to display negative values within parenthesis?

antsi klando
Ranch Hand

Joined: May 10, 2011
Posts: 46
I want the values to be within parenthesis when the values are negative and the values displayed normally.

Example:<display:column property="Rebate"
format="$ {0,number,###,###,###,###.00}" title="Total Amount"/>

This formatting will only result in $ 123.00

what if the value is negative?
It will result in $ -123.00

As we have <fmt:formatNumber type="number" pattern="#########"/> for <input> tags,how will we display it using <display:column>?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

display is not a standard JSP tag library. What is it? How can we help if you don't even tell us what libraries you are using?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
antsi klando
Ranch Hand

Joined: May 10, 2011
Posts: 46
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>


These are the libraries used
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

It would have helped if you had posted a link to the displaytag home page at least. Still, it wasn't hard to google. And it wasn't hard to find the documentation for that tag. In which it says that the format attribute gets a string which is a MessageFormat string.

MessageFormat is a Java class, so look up its documentation. Hint: if you want to have different formats for different ranges of numbers then "choice" is the keyword for that. Check out the examples in the documentation.
antsi klando
Ranch Hand

Joined: May 10, 2011
Posts: 46
how will I solve this issue?I did not understand
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

Step 1: Look at the API documentation for Java. Surely you must already have a bookmark for that, I find it's very difficult to write Java without referring to the documentation.

Step 2: Find the documentation for the MessageFormat class. It's in the java.text package, I think, but at any rate there's an index you can look in (the "Index" link at the top of every page).

Step 3: Read that documentation (which has quite a few examples) and find the example which suits your question.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to display negative values within parenthesis?