Re: Java Newb

From: Denz (RUBBISH_at_RUBBISHhotmail.com)
Date: 01/25/04


Date: Sun, 25 Jan 2004 22:34:10 GMT


"Robert Tyrie" <robtyrie@yahoo.ca> wrote in message
news:opr2berkd4shq0lc@news.cogeco.ca...
> On Sat, 24 Jan 2004 21:40:43 -0500, Travis Ray <travrichard@comcast.net>
> wrote:
>
> > Or is there a way to align columns other than putting spacer
> > strings inbetween data elements?
>
> Take a look at the DecimalFormat class,
>
> http://java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormat.html

As an *exercise*, might also want to do the formatting manually?
... by using String .indexOf('.') and .length() methods to determine how
many charaters after the decimal point, then add the append the appropriate
number of zeros to give you two decimal places. For alligning columns,
probably need to use .length() on individual strings to determine how many
spaces to use in padding to get column alignment.



Relevant Pages

  • Re: java.text.DecimalFormat
    ... > Note that Sun's jvm produces "2199.76" for both strings. ... > Is it simply a bug in DecimalFormat? ...
    (microsoft.public.dotnet.vjsharp)
  • Re: Java Newb
    ... If your problem is text formatting for number strings, ... java.text.Format and its derivatives -- especially DecimalFormat. ...
    (comp.lang.java)