MIDRANGE dot COM Mailing List Archive



Home » JAVA400-L » September 2009

Re: String tokenizer problem



fixed

The String#split method worked fine so I was able to get around it that
way. This seems like a bug but I certainly could be missing something.

Thanks,
Todd Allen
EDPS
Electronic Data Processing Services
tallen@xxxxxxxxxxxx




James Perkins
<jrperkinsjr@gmai
l.com> To
Sent by: "Java Programming on and around the
java400-l-bounces iSeries / AS400"
@midrange.com <java400-l@xxxxxxxxxxxx>
cc

2009-09-30 14:55 Subject
Re: String tokenizer problem

Please respond to
Java Programming
on and around the
iSeries / AS400
<java400-l@midran
ge.com>






I couldn't get it to work either. I even tried getting rid of the plus and
the colon. Nothing seemed to work. Very strange.

I did get the java.util.Scanner to work though. You can use that at Java 5
or higher.


String text = "Sep 29, 2009 7:00 PM GMT+00:00 Sep 30, 2009 7:30 PM
GMT+00:00";
Scanner s = new Scanner(text);
s.useDelimiter("GMT\\+00:00");
while (s.hasNext()) {
System.out.println(s.next());
}

Hope this helps.
--
James R. Perkins
http://twitter.com/the_jamezp


On Wed, Sep 30, 2009 at 11:08, <TAllen@xxxxxxxxxxxx> wrote:

I'm having some trouble with the StringTokenizer. As far as I can tell
there is something wacky going on due to the + or : in the delimiter.
I have the following string:
Sep 29, 2009 7:00 PM GMT+00:00 Sep 30, 2009 7:30 PM GMT+00:00

I am using "GMT+00:00" (no quotes) as the delimiter.

The String#split method correctly splits the string in to the array
elements using a simple regex:
String[] tokens = text.split("GMT\\+00:00");

The StringTokenizer splits on the first double zero in 2009 and then
stops
at the colon in the time next:
StringTokenizer t = new StringTokenizer(text, "GMT+00:00");

The 1st two tokens are:
Sep 29, 2
9 7

Has anyone seen this behavior before? Am I missing something obvious?

Thanks,
Todd Allen
EDPS
Electronic Data Processing Services
tallen@xxxxxxxxxxxx



This communication and any transmitted documents are intended to be
confidential. If there is a problem with this transmission, please
contact
the sender. If the reader of this message is not the intended recipient,
or
the employee or agent responsible to deliver it to the intended
recipient,
you are hereby notified that any dissemination, distribution or copying
of
this communication is strictly prohibited.

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


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





This communication and any transmitted documents are intended to be confidential. If there is a problem with this transmission, please contact the sender. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.






Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot 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 here. If you have questions about this, please contact