🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #548

How to parse formated number-strings

#548
From: 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
Technical Details
Message-ID: <42cd1924$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!newspeer.monmouth.com!newsfeed.icl.net!newsfeed.fjserv.net!easynet-quince!easynet.net!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!217.73.144.45.MISMATCH!feeder2.ecngs.de!ecngs!feeder.ecngs.de!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,c2764cfb09221f42,start
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Thu, 07 Jul 2005 07:59:57 -0400
From: Magnus <magnus_bjorkman@iwon.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)
X-Accept-Language: en-us, en, sv
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: How to parse formated number-strings
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 69.69.73.170
Message-ID: <42cd1924$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1120737572 69.69.73.170 (7 Jul 2005 04:59:32 -0700)
Lines: 22
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!newspeer.monmouth.com!newsfeed.icl.net!newsfeed.fjserv.net!easynet-quince!easynet.net!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!217.73.144.45.MISMATCH!feeder2.ecngs.de!ecngs!feeder.ecngs.de!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail