Not Getting a match on Dates

[email protected] Mon, 10 Mar 2003 08:56:15 -0500
Newsgroups gmane.comp.jakarta.oro.user
Message-ID <OF82A3414D.E88F31F6-ON85256CE5.004A41F1-85256CE5.004C8FAF@baglobal.com>
Hello all,

Could you someone please help me out with this problem I having...

I'm trying to find all the line that begin with a Date in the following
format: MM/DD/YY, however when I run the program I get matches on some
lines and other lines that don't... I'm not to sure on why this is
occurring...since all the data is formatted the same way. I trying to
create a program that takes the below data and formats it like so:
CallDate|CustomerNumber|CustomerName|TollCount|FileName|FileDate for
Database importing....Could someone help in pointing out my errors...

Thanks in advance....

***** Data that is being Searched ******

filename: "R105842M.fxw"
Sat Feb 22 09:22:44 CST 2003

CUSTOMER NUMBER: 105842
CUSTOMER NAME: SomeCustomer , INC

       CALL DATE             CUSTOMER NUMBER           TOLL COUNT
       ------------------              ----------------------------------
--------------------
       01/31/03                      105842                             1
                  <----- All these lines get no match...
       02/03/03                     105842                              9
       02/04/03                     105842                              11
       02/05/03                      105842                             9


**** Code ****

            try
            {
                  matchFileName           = compiler.compile("Filename: ");
                  matchCustomerNumber     = compiler.compile("CUSTOMER
NUMBER: ");
                  matchCustomerName             = compiler.compile
("CUSTOMER NAME: ");
                  matchCallDate                 = compiler.compile("\\A
(\\d\\d/\\d\\d/\\d\\d)");
            }
            catch (MalformedPatternException mpe)
            {
                  mpe.printStackTrace();
                  log.fatal("The was a MalformedPatternException was
caught, when trying to compiler patterns" +
                                 "please conduct researching into this." +
newLine + mpe);
            }
            try{

            while ((line = input.readLine()) !=null)
            {
                  log.debug("The following line is being processed" +
newLine + line);

                  if(matcher.contains(line, matchFileName))
                  {
                        log.debug("found match: " + line);
                        StringTokenizer token = new StringTokenizer(line);
                        token.nextToken();
                        fileName = token.nextToken();

                        /*To get rid of the quotes*/
                        fileName = fileName.substring(1, 13);
                        log.info("Filename is: " + fileName);

                        log.debug("Since FileName was found, the next line
will have the fileDate." + newLine +
                                       NextLine);

                        String NextLine = input.readLine();

                        StringTokenizer aDateTok = new StringTokenizer
(NextLine);

                        aDateTok.nextToken();  //This is the Day of the
week...which is currently not needed.
                        String month            = aDateTok.nextToken();
                        String day        = aDateTok.nextToken();
                        String time             = aDateTok.nextToken();
                        aDateTok.nextToken();   //TimeZone infomation...not
needed at this time.
                        String year       = aDateTok.nextToken();

                        fileDate = (month +" "+ day +", " + year + " " +
time);
                        log.info("The file Date created was: " + fileDate);
                  }
                  else if (matcher.contains(line, matchCustomerName))
                  {
                        log.debug("found match: " + line);
                        customerName = line;
                        int numberOfCharacters = customerName.length();
                        customerName = customerName.substring(15,
numberOfCharacters);
                  }
                  else if (matcher.contains(line, matchCallDate))
                  {
                        log.debug("found match: " + line);
                        StringTokenizer callDateToken  = new
StringTokenizer(line);
                        callDate                = callDateToken.nextToken
();
                        customerNumber          = callDateToken.nextToken
();
                        tollCount               = callDateToken.nextToken
();

                        out.println(callDate + "|" + customerNumber + "|" +
customerName + "|" +
                                          tollCount + "|" + fileName + "|"
+ fileDate);

                  }
                  else
                  {
                        if (getJunkData.equalsIgnoreCase("true"))
                        {
                              junkOut.println ("No match was found for
line: "+ line);
                        }
                        continue;
                  }
            }
            }