コード例 #1
0
ファイル: AbstractDateTimeDV.java プロジェクト: rhusar/xerces
  /**
   * Parses time zone: 'Z' or {+,-} followed by hh:mm
   *
   * @param data
   * @param sign
   * @exception RuntimeException
   */
  protected void getTimeZone(String buffer, DateTimeData data, int sign, int end)
      throws RuntimeException {
    data.utc = buffer.charAt(sign);

    if (buffer.charAt(sign) == 'Z') {
      if (end > (++sign)) {
        throw new RuntimeException("Error in parsing time zone");
      }
      return;
    }
    if (sign <= (end - 6)) {

      int negate = buffer.charAt(sign) == '-' ? -1 : 1;
      // parse hr
      int stop = ++sign + 2;
      data.timezoneHr = negate * parseInt(buffer, sign, stop);
      if (buffer.charAt(stop++) != ':') {
        throw new RuntimeException("Error in parsing time zone");
      }

      // parse min
      data.timezoneMin = negate * parseInt(buffer, stop, stop + 2);

      if (stop + 2 != end) {
        throw new RuntimeException("Error in parsing time zone");
      }
      if (data.timezoneHr != 0 || data.timezoneMin != 0) data.normalized = false;
    } else {
      throw new RuntimeException("Error in parsing time zone");
    }
    if (DEBUG) {
      System.out.println("time[hh]=" + data.timezoneHr + " time[mm]=" + data.timezoneMin);
    }
  }
コード例 #2
0
ファイル: AbstractDateTimeDV.java プロジェクト: rhusar/xerces
 /* (non-Javadoc)
  * @see org.apache.xerces.xs.datatypes.XSDateTime#normalize()
  */
 public XSDateTime normalize() {
   if (!normalized) {
     DateTimeData dt = (DateTimeData) this.clone();
     dt.normalized = true;
     return dt;
   }
   return this;
 }