[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-commons-user
Subject: Re: utils to display currency for any bigdecimal
From: Ted Dunning <ted.dunning () gmail ! com>
Date: 2009-07-15 19:17:50
Message-ID: c7d45fc70907151217l9b3982ene018157e64800b1 () mail ! gmail ! com
[Download RAW message or body]
As I suggested previously:
public void testFormatBigDecimal() {
BigDecimal x = new BigDecimal("12345678.43");
assertEquals("$12,345,678.43", String.format("$%,.2f", x));
}
On Wed, Jul 15, 2009 at 11:54 AM, fachhoch <fachhoch@gmail.com> wrote:
>
> I asking If there is any simpler way to do this right now I doing it
>
> NumberFormat.getCurrencyInstance().format(ObjectUtils.defaultIfNull(stgFinding.getFindingAmt(),
> new BigDecimal(0)))
> NumberFormat.getCurrencyInstance().format throws exception if the object
> passed to it is null ,I am aksing if there is anything available with
> commons utils which takes care of this internally ?
>
> Ted Dunning wrote:
> >
> > I find manuals very handy for questions like this:
> >
> >
> http://java.sun.com/j2se/1.5.0/docs/api/java/io/PrintWriter.html#printf(java.lang.St \
> ring,%20java.lang.Object<http://java.sun.com/j2se/1.5.0/docs/api/java/io/PrintWriter.html#printf%28java.lang.String,%20java.lang.Object>
>
> ..
> > .)
> >
> >
> http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#format(java.lang.Strin \
> g,%20java.lang.Object<http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#format%28java.lang.String,%20java.lang.Object>
>
> ..
> > .)
> >
> >
> >
> > On Wed, Jul 15, 2009 at 10:28 AM, tubin gen <fachhoch@gmail.com> wrote:
> >
> > > Is there any utils to display a bigdecimal with $56,98
> > > for example is there any utils which takes a bigdecimal , does not
> throw
> > > exception if it is null and if not then formats to comma seperated
> > > number
> > > with $ symbol before ?
> > >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/utils-to-display-currency-for-any-bigdecimal-tp24502491p24503798.html
> Sent from the Commons - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
--
Ted Dunning, CTO
DeepDyve
111 West Evelyn Ave. Ste. 202
Sunnyvale, CA 94086
http://www.deepdyve.com
858-414-0013 (m)
408-773-0220 (fax)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic