예제 #1
0
  @Override
  public Timestamp getTimestamp(Calendar cal) throws SQLException {
    Timestamp ts;

    if (jsonObject == null) {
      isNull = true;
      return null;
    }

    try {
      if (jsonObject instanceof java.util.Date || jsonObject instanceof java.sql.Date) {
        ts = new Timestamp(((java.util.Date) jsonObject).getTime());
      } else if (jsonObject instanceof String) {
        ts = timestampUtils.parseTimestamp((String) jsonObject);
      } else {
        throw new SQLException("value " + jsonObject + " is not a Timestamp");
      }
    } catch (Exception ex) {
      throw new SQLException("value " + jsonObject + "is not a Timestamp", ex);
    }

    if (cal != null) {
      ts = timestampUtils.applyCalendar(cal, ts);
    }
    /*
    // check to see if there is a calendar and that it is different than the one used to parse
    */
    return ts;
  }
예제 #2
0
  @Override
  public Date getDate(Calendar cal) throws SQLException {
    Date date = null;

    if (jsonObject == null) {
      isNull = true;
      return null;
    }

    try {
      if (jsonObject instanceof String) {
        date = timestampUtils.parse((String) jsonObject);
      }
      if (jsonObject instanceof Date) {
        date = (Date) jsonObject;
      }
      if (jsonObject instanceof java.util.Date) {
        date = new Date(((java.util.Date) jsonObject).getTime());
      }
    } catch (Exception ex) {
      throw new SQLException("value " + jsonObject + " is not a date");
    }

    if (cal != null) {
      date = timestampUtils.applyCalendar(cal, date);
    }

    return date;
  }
예제 #3
0
  @Override
  public Time getTime(Calendar cal) throws SQLException {
    Time time;

    if (jsonObject == null) return null;

    try {
      time = timestampUtils.parseTime((String) jsonObject);
    } catch (Exception ex) {
      throw new SQLException("value " + jsonObject + " is not a Time", ex);
    }

    if (cal != null) {
      time = timestampUtils.applyCalendar(cal, time);
    }
    return time;
  }