Exemplo n.º 1
0
  /**
   * Parse a validated date. This is invoked from XSDDatatype.convertValidatedDataValue rather then
   * from a local parse method to make the implementation of XSDGenericType easier.
   */
  public Object parseValidated(String str) {
    int len = str.length();
    int[] date = new int[TOTAL_SIZE];
    int[] timeZone = new int[2];

    // set constants
    date[CY] = YEAR;
    date[D] = DAY;
    int stop = 4;
    date[M] = parseInt(str, 2, stop);

    // REVISIT: allow both --MM and --MM-- now.
    // need to remove the following 4 lines to disallow --MM--
    // when the errata is offically in the rec.
    if (str.length() >= stop + 2 && str.charAt(stop) == '-' && str.charAt(stop + 1) == '-') {
      stop += 2;
    }
    if (stop < len) {
      int sign = findUTCSign(str, stop, len);
      getTimeZone(str, date, sign, len, timeZone);
    }

    if (date[utc] != 0 && date[utc] != 'Z') {
      AbstractDateTime.normalize(date, timeZone);
    }

    return new XSDDateTime(date, MONTH_MASK);
  }
Exemplo n.º 2
0
  @Override
  protected AbstractDateTime parse(String str) {
    int len = str.length();
    int[] date = new int[TOTAL_SIZE];
    int[] timeZone = new int[2];

    // get date
    int end = getYearMonth(str, 0, len, date);
    date[D] = DAY;
    parseTimeZone(str, end, len, date, timeZone);

    // validate and normalize
    validateDateTime(date, timeZone);

    if (date[utc] != 0 && date[utc] != 'Z') {
      AbstractDateTime.normalize(date, timeZone);
    }

    return new XSDDateTime(date, YEAR_MASK | MONTH_MASK);
  }