Beispiel #1
0
 /**
  * Initializes the yearMonth component.
  *
  * @param vl value
  * @param mt matcher
  * @param ii input info
  * @throws QueryException query exception
  */
 void yearMonth(final byte[] vl, final Matcher mt, final InputInfo ii) throws QueryException {
   final long y = mt.group(2) != null ? toLong(mt.group(3), true, ii) : 0;
   final long m = mt.group(4) != null ? toLong(mt.group(5), true, ii) : 0;
   mon = y * 12 + m;
   double v = y * 12d + m;
   if (!mt.group(1).isEmpty()) {
     mon = -mon;
     v = -v;
   }
   if (v <= Long.MIN_VALUE || v >= Long.MAX_VALUE) throw DURRANGE_X_X.get(ii, type, vl);
 }
Beispiel #2
0
  /**
   * Initializes the dayTime component.
   *
   * @param vl value
   * @param mt matcher
   * @param p first matching position
   * @param ii input info
   * @throws QueryException query exception
   */
  void dayTime(final byte[] vl, final Matcher mt, final int p, final InputInfo ii)
      throws QueryException {

    final long d = mt.group(p) != null ? toLong(mt.group(p + 1), true, ii) : 0;
    final long h = mt.group(p + 3) != null ? toLong(mt.group(p + 4), true, ii) : 0;
    final long m = mt.group(p + 5) != null ? toLong(mt.group(p + 6), true, ii) : 0;
    final BigDecimal s =
        mt.group(p + 7) != null ? toDecimal(mt.group(p + 8), true, ii) : BigDecimal.ZERO;
    sec =
        s.add(BigDecimal.valueOf(d).multiply(DAYSECONDS))
            .add(BigDecimal.valueOf(h).multiply(BD3600))
            .add(BigDecimal.valueOf(m).multiply(BD60));
    if (!mt.group(1).isEmpty()) sec = sec.negate();
    final double v = sec.doubleValue();
    if (v <= Long.MIN_VALUE || v >= Long.MAX_VALUE) throw DURRANGE_X_X.get(ii, type, vl);
  }