Let's assume that Marty's code gets you a string, call it abc.
Then to right align the string in a column:
int padding = width - abc.length();
while (--padding >= 0) System.out.print(" ");
System.out.print(abc);
where width is the column width you are using.
"Marty" <ic*******@hotmail.com> wrote in message
news:Qi*******************@rwcrnsc51.ops.asp.att.n et...
NumberFormat nf = NumberFormat.getCurrencyInstance();
nf.format(double);
will get you a double formatted to local currency
"Dennis" <ml***@yahoo.com> wrote in message
news:2f**************************@posting.google.c om... I'm trying to output currency columns to the console in table format.
I need a class that allows me to format doubles to currency and have
the columns right-justified. I've come up with a ridiculously
convoluted way to use MessageFormat() to do this, but there's got to
be a better way.
Is there a class that's good for this? There has to be. (I'm just
learning my way around Java).
Thanks.
Dennis