Examples of GDataParseException


Examples of org.apache.lucene.gdata.gom.core.GDataParseException

      throw new IllegalArgumentException(
          "Date-Time String must not be null");
    Matcher aMatcher = RFC3339_DATE_PATTERN.matcher(aString);

    if (!aMatcher.matches()) {
      throw new GDataParseException(
          "Invalid RFC3339 date / time pattern -- " + aString);
    }
    int grCount = aMatcher.groupCount();
    if (grCount > 13)
      throw new GDataParseException(
          "Invalid RFC3339 date / time pattern -- " + aString);

    Integer timeZoneShift = null;
    Calendar dateTime = null;
    try {

      if (aMatcher.group(9) == null) {
        // skip time zone
      } else if (aMatcher.group(9).equalsIgnoreCase("Z")) {
        timeZoneShift = new Integer(0);
      } else {
        timeZoneShift = new Integer((Integer
            .valueOf(aMatcher.group(12)) * 60 + Integer
            .valueOf(aMatcher.group(13))));
        if (aMatcher.group(11).equals("-")) {
          timeZoneShift = new Integer(-timeZoneShift.intValue());
        }
      }

      dateTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
      ;
      dateTime.clear();
      dateTime.set(Integer.valueOf(aMatcher.group(1)), Integer
          .valueOf(aMatcher.group(2)) - 1, Integer.valueOf(aMatcher
          .group(3)), Integer.valueOf(aMatcher.group(4)), Integer
          .valueOf(aMatcher.group(5)), Integer.valueOf(aMatcher
          .group(6)));
      // seconds with milliseconds
      if (aMatcher.group(8) != null && aMatcher.group(8).length() > 0) {

        dateTime.set(Calendar.MILLISECOND, new BigDecimal("0."/*
                                     * use
                                     * big
                                     * dec
                                     * this
                                     * could
                                     * be
                                     * big!!
                                     */
            + aMatcher.group(8)).movePointRight(3).intValue());
      }
    } catch (NumberFormatException e) {
      throw new GDataParseException(
          "Invalid RFC3339 date / time pattern -- " + aString, e);
    }

    long retVal = dateTime.getTimeInMillis();
    if (timeZoneShift != null) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.