× 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.



Yes, I did leave out the comma in my example. I keyed it into the email instead and forgot it, though I'll admit I've tried it both ways. Ha! Seems the replace will allow replace(',','space') but not replace(',','') it complains that it is an invalid character constant. The replace(",","") gives me the error that a string is not allowed as character arguments.

Ha, I guess I'm getting close and on a similar track that I earlier thought. I first thought of cleaning the string prior to converting it to a BigDecimal, but I was hoping there was a way to do this without having to clean up the string ,such as a some sort of switch or argument value or setting that would ignore comma's conversions such as this.

I'll read the link that Joe sent me, titled 'Resolving NumberFormat's parsing issues'. This sounds like it may have been written for me.

Thanks to all, I really appreciate everyone's help on this. And with me, things such as not putting comma's between arguments is something I'm certainly capable of doing. I've written a few fairly hefty applications now using Java, but it all still seems foreign to me. I'm not yet close to the Java comfort zone.

----- Original Message ----- From: "Pete Hall" <pbhall@xxxxxxxxxxxxx> To: "Java Programming on and around the iSeries / AS400" <java400-l@xxxxxxxxxxxx>
Sent: Wednesday, December 20, 2006 6:00 PM
Subject: Re: Converting a string to BigDecimal w/comma


-----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-----
--
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.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.