🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.language
3 messages
3 total messages Started by Magnus Thu, 07 Jul 2005 11:59
How to parse formated number-strings
#548
Author: Magnus
Date: Thu, 07 Jul 2005 11:59
22 lines
1809 bytes
Hi,

When displaying double values in textfields I use:

double tmp = Double.parseDouble(stringWithDouble.getText());
sizeTextField.setText(String.valueOf(df0.format(tmp))); 
//df0.applyPattern("###,###") i.e. 0 decimals

If the stringWithDouble is formatted to ex. 1,234 I get:

java.lang.NumberFormatException: For input string: "134,099"
  at 
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)

  at 
java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1207)
  at java.lang.Double.parseDouble(Double.java:220)

I think there is a way to use formatting when parsing strings but I 
can't find it.

Magnus
Re: How to parse formated number-strings
#550
Author: Gillmer J. Derge [TeamB]
Date: Mon, 11 Jul 2005 16:40
8 lines
1241 bytes
Magnus wrote:
> I think there is a way to use formatting when parsing strings but I 
> can't find it.

double tmp = df0.parse(stringWithDouble.getText()).doubleValue();

-- 
Gillmer J. Derge [TeamB]
Re: How to parse formated number-strings
#551
Author: Magnus
Date: Mon, 11 Jul 2005 17:29
11 lines
1346 bytes
That was what I was looking for, thanks!

Gillmer J. Derge [TeamB] wrote:
> Magnus wrote:
> 
>> I think there is a way to use formatting when parsing strings but I 
>> can't find it.
> 
> 
> double tmp = df0.parse(stringWithDouble.getText()).doubleValue();
> 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads