code: private boolean checkValueAndNext(StringTokenizer st, String token) throws
        InvalidDateException
    {
      if (!st.hasMoreTokens())
      {
        return false;
      }
      String t = st.nextToken();
      if (!t.equals(token))
      {
        throw new InvalidDateException("Unexpected: " + t);
      }
      if (!st.hasMoreTokens())
      {
        throw new InvalidDateException("Incomplete date.");
      }
      return true;
    }
docs: Check if the next token, if exists, has a given value and that the
  provided string tokenizer has more tokens after that. It consumes
  the token checked against the expected value from the string tokenizer.
  
  @param st    The StringTokenizer to check.
  @param token The value expected for the next token.
  @return <code>true</code> if the token matches the value and there are more tokens.
  <code>false</code> if there are no more tokens and we do not have a token to check.
  @throws InvalidDateException If the token does not match the value or if there are no
  more tokens after the token that matches the expected value.