You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rouven Gehm <r....@teckpro.de> on 2003/11/21 13:48:34 UTC

[OT] : FormatKey how to set a format

Hi,

its a little bit of topic, i have the problem, i want to show
doubles on my jsps.
I now use following format : #,##
which works quite good, but it cuts of the 0 at the end.
E.g. i have 17,56546546 it show 17,57
i have 17,50001 it shows 17,5
but i want 17,50.

Is there another format i can use ? 
Or do i have to create Strings and add the missing 0s ?

Thanx

Rouven


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: [OT] : FormatKey how to set a format

Posted by Kirk Wylie <kw...@m7.com>.
Are you absolutely sure you want to use doubles to store currency 
values? RDBMS systems have fixed-precision data types for exactly that 
reason.

While doubles are convenient, they can result in unintended consequences 
such as issues with .00001 appearing places that it probably shouldn't.

Kirk Wylie
M7 Corporation

Rouven Gehm wrote:
> Hi,
> 
> it works not quite well, but if i actually have a 17,5
> it still only shows 17,5 not 17,50.
> 
> I can of course add 0.00001 to 17,5 but thats hmm a hell of a hack.
> 
> As i want to use it to show currencys, i wonder if i can use
> the NumberFormat.Field CURRENCY ???
> 
> 
> Thanx
> 
> ----- Original Message -----
> From: "Markus" <ma...@gmx.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Friday, November 21, 2003 1:51 PM
> Subject: Re: [OT] : FormatKey how to set a format
> 
> 
>  > > Hi,
>  > >
>  > > its a little bit of topic, i have the problem, i want to show
>  > > doubles on my jsps.
>  > > I now use following format : #,##
>  > Hi,
>  > try #,00! This should work.
>  > For a deeper look go to JavaAPI NumberFormat classes
>  > Regards,
>  > Markus
>  > > which works quite good, but it cuts of the 0 at the end.
>  > > E.g. i have 17,56546546 it show 17,57
>  > > i have 17,50001 it shows 17,5
>  > > but i want 17,50.
>  > >
>  > > Is there another format i can use ?
>  > > Or do i have to create Strings and add the missing 0s ?
>  > >
>  > > Thanx
>  > >
>  > > Rouven
>  > >
>  > >
>  > > ---------------------------------------------------------------------
>  > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>  > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
>  > >
>  >
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>  > For additional commands, e-mail: struts-user-help@jakarta.apache.org
>  >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: [OT] : FormatKey how to set a format

Posted by Rouven Gehm <r....@teckpro.de>.
Hi,

it works not quite well, but if i actually have a 17,5
it still only shows 17,5 not 17,50.

I can of course add 0.00001 to 17,5 but thats hmm a hell of a hack.

As i want to use it to show currencys, i wonder if i can use
the NumberFormat.Field CURRENCY ???


Thanx

----- Original Message ----- 
From: "Markus" <ma...@gmx.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, November 21, 2003 1:51 PM
Subject: Re: [OT] : FormatKey how to set a format


> > Hi,
> > 
> > its a little bit of topic, i have the problem, i want to show
> > doubles on my jsps.
> > I now use following format : #,##
> Hi,
> try #,00! This should work.
> For a deeper look go to JavaAPI NumberFormat classes
> Regards,
> Markus
> > which works quite good, but it cuts of the 0 at the end.
> > E.g. i have 17,56546546 it show 17,57
> > i have 17,50001 it shows 17,5
> > but i want 17,50.
> > 
> > Is there another format i can use ? 
> > Or do i have to create Strings and add the missing 0s ?
> > 
> > Thanx
> > 
> > Rouven
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: [OT] : FormatKey how to set a format

Posted by Markus <ma...@gmx.com>.
> Hi,
> 
> its a little bit of topic, i have the problem, i want to show
> doubles on my jsps.
> I now use following format : #,##
Hi,
try #,00! This should work.
For a deeper look go to JavaAPI NumberFormat classes
Regards,
Markus
> which works quite good, but it cuts of the 0 at the end.
> E.g. i have 17,56546546 it show 17,57
> i have 17,50001 it shows 17,5
> but i want 17,50.
> 
> Is there another format i can use ? 
> Or do i have to create Strings and add the missing 0s ?
> 
> Thanx
> 
> Rouven
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org