Weird Problem w/ DecimalFormat  
Author Message
Cliff





PostPosted: 2004-5-11 11:26:00 Top

java-programmer, Weird Problem w/ DecimalFormat The following code snippet:

static DecimalFormat nf=new DecimalFormat("#####.00");
System.out.println(nf.format(1000.10));

sometimes stops working properly and instead of seeing 1000.10 I see 1000,10
(note the comma). I can't for the life of me figure out what is going on...
I'm using Java 1.3.1 on a Sun workstation.

Any ideas?

Cliff


 
Thomas Weidenfeller





PostPosted: 2004-5-11 15:42:00 Top

java-programmer >> Weird Problem w/ DecimalFormat Cliff wrote:
> The following code snippet:
>
> static DecimalFormat nf=new DecimalFormat("#####.00");
> System.out.println(nf.format(1000.10));
>
> sometimes stops working properly

Sounds like it works as advertised.

> and instead of seeing 1000.10 I see 1000,10
> (note the comma). I can't for the life of me figure out what is going on...
> I'm using Java 1.3.1 on a Sun workstation.

Check the settings of your locale (LANG and LC_ environment variables,
etc.). Not everyone in the world uses the '.' as the decimal delimiter.

/Thomas
 
Andy Fish





PostPosted: 2004-5-11 17:21:00 Top

java-programmer >> Weird Problem w/ DecimalFormat
"Thomas Weidenfeller" <email***@***.com> wrote in message
news:c7q002$fvf$email***@***.com...
> Cliff wrote:
> > The following code snippet:
> >
> > static DecimalFormat nf=new DecimalFormat("#####.00");
> > System.out.println(nf.format(1000.10));
> >
> > sometimes stops working properly
>
> Sounds like it works as advertised.
>
> > and instead of seeing 1000.10 I see 1000,10
> > (note the comma). I can't for the life of me figure out what is going
on...
> > I'm using Java 1.3.1 on a Sun workstation.
>
> Check the settings of your locale (LANG and LC_ environment variables,
> etc.). Not everyone in the world uses the '.' as the decimal delimiter.

I think you need to define "sometimes". I would be very surprised if it
behaves this way intermittently in a consistent environment. Once you have
figured out the difference in environment you have the answer.

Often these kind of things work one way when you run it in the development
environment or when loggged on interactively, but a different way when you
install it in the services control panel (NT), or have it run as an rc
script (*x)



>
> /Thomas


 
 
Fred





PostPosted: 2004-5-12 10:32:00 Top

java-programmer >> Weird Problem w/ DecimalFormat I may be totally off the mark here, but I believe that you need to adjust
your location settings in your operating system. You have your system
number format set to the European standard where they use a comma instead of
a period (ie: 1000,10 instead of 1000.10). That would explain the comma
coming up instead of the period.

Hope this helps,

Fred.

"Cliff" <email***@***.com> wrote in message
news:TIXnc.12164$Lm3.10664@lakeread04...
> The following code snippet:
>
> static DecimalFormat nf=new DecimalFormat("#####.00");
> System.out.println(nf.format(1000.10));
>
> sometimes stops working properly and instead of seeing 1000.10 I see
1000,10
> (note the comma). I can't for the life of me figure out what is going
on...
> I'm using Java 1.3.1 on a Sun workstation.
>
> Any ideas?
>
> Cliff
>
>


 
 
Fred





PostPosted: 2004-5-12 10:35:00 Top

java-programmer >> Weird Problem w/ DecimalFormat You may need to adjust the location settings of your operating system. It
sounds like you have your system set to the European standard where the
comma takes the place of the period.

Hope this helps,

Fred.

"Andy Fish" <email***@***.com> wrote in message
news:8W0oc.41$email***@***.com...
>
> "Thomas Weidenfeller" <email***@***.com> wrote in message
> news:c7q002$fvf$email***@***.com...
> > Cliff wrote:
> > > The following code snippet:
> > >
> > > static DecimalFormat nf=new DecimalFormat("#####.00");
> > > System.out.println(nf.format(1000.10));
> > >
> > > sometimes stops working properly
> >
> > Sounds like it works as advertised.
> >
> > > and instead of seeing 1000.10 I see 1000,10
> > > (note the comma). I can't for the life of me figure out what is going
> on...
> > > I'm using Java 1.3.1 on a Sun workstation.
> >
> > Check the settings of your locale (LANG and LC_ environment variables,
> > etc.). Not everyone in the world uses the '.' as the decimal delimiter.
>
> I think you need to define "sometimes". I would be very surprised if it
> behaves this way intermittently in a consistent environment. Once you have
> figured out the difference in environment you have the answer.
>
> Often these kind of things work one way when you run it in the development
> environment or when loggged on interactively, but a different way when you
> install it in the services control panel (NT), or have it run as an rc
> script (*x)
>
>
>
> >
> > /Thomas
>
>


 
 
Roedy Green





PostPosted: 2004-5-12 10:59:00 Top

java-programmer >> Weird Problem w/ DecimalFormat On Mon, 10 May 2004 23:25:34 -0400, "Cliff" <email***@***.com> wrote
or quoted :

>sometimes stops working properly and instead of seeing 1000.10 I see 1000,10
>(note the comma). I can't for the life of me figure out what is going on...
>I'm using Java 1.3.1 on a Sun workstation.

Swedes like to use commas where we use dot. Use Wassup to find out
what you have selected for your international settings.

see http://mindprod.com/jgloss/wassup.html

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.