× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Don,

Aren't you missing a comma between the arguments?
...strTotal.replace(",","");

Pete Hall
pbhall@xxxxxxxxxxxxx
http://pbhall.us


Don McIntyre wrote:
Thanks for your response David,

I tried replace() because I don't believe replaceAll() is available at my 
J2EE level.  I'm on OS/400 5.2 using Websphere 5.1. I believe I'm at J2EE 
level 1.3.

The problem with replace() is it seems to be expecting character arguments. 
...strTotal.replace("," "");  does not work, nor does 
...strTotal.replace(',' '');

----- Original Message ----- 
From: "David Gibbs" <david@xxxxxxxxxxxx>
Newsgroups: midrange.java400-l
To: <java400-l@xxxxxxxxxxxx>
Sent: Wednesday, December 20, 2006 4:28 PM
Subject: Re: Converting a string to BigDecimal w/comma


Don McIntyre wrote:
I am loading a DB2/400 data base table from an XML file.  I was not
having problems until a vendor started adding comma's in the 'total'
element of the XML.  Now my program errors when trying to write the
amount field to a Big Decimal.  The cXML consortium states the comma is
optional, so I need to deal with it.
Editing a numeric value in a data file is pretty dumb.

How about extracting the value into a String, then use the replaceAll
method to replace commas with nothing.

Something like ...

String editedNumericValue = "123,456,789.01"; // get the value here
String rawNumericValue = editedNumericValue.replaceAll(",","");

Of course the best solution would be to have the vendor create the xml
file properly.

david

-- 
Check out the System i Search Engine: http://search.midrange.com
-- 
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) 
mailing list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFic6HpcZsDl8OX6kRAoELAJ9xmHnDnZuSd6Hf6ZvNpAhkoLDkTQCaA09d
Te8fbT4qc61sYwwLP2ZPrhw=
=h15v
-----END PGP SIGNATURE-----

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.