APISonar


org.apache.geode.pdx.FieldType.DATE

> org > apache > geode > pdx > FieldType > DATE
org APIs apache APIs geode APIs pdx APIs FieldType APIs DATE APIs

Example 1
public PdxWriter writeDate(String fieldName, Date date) {
    if (date != null && !Date.class.equals(date.getClass())) {
      // fix for bug 43717
      throw new IllegalArgumentException(
          "writeDate only accepts instances of Date. Subclasses are not supported. Use writeObject for subclasses of Date.");
    }
    updateMetaData(fieldName, FieldType.DATE);
    this.os.writeDate(date);
    return this;
  }
Example 2
public void readOfDateFieldWithDateColumnWritesDate() throws Exception {
    FieldType fieldType = FieldType.DATE;
    when(metaData.getColumnType(1)).thenReturn(Types.DATE);
    java.sql.Date sqlDate = java.sql.Date.valueOf("1979-09-11");
    Date expectedValue = new Date(sqlDate.getTime());
    when(resultSet.getDate(1)).thenReturn(sqlDate);
    sqlToPdxInstance.addMapping(COLUMN_NAME_1, PDX_FIELD_NAME_1, fieldType);

    PdxInstance result = createPdxInstance();

    verifyResult(expectedValue, result);
  }
Example 3
public Date readDate(String fieldName) {
    PdxField ft = blobType.getPdxField(fieldName);
    if (ft == null) {
      return null;
    }
    if (ft.getFieldType() != FieldType.DATE) {
      throw new PdxFieldTypeMismatchException(
          "Expected Date field but found field of type " + ft.getTypeIdString());
    }
    return readDate(ft);
  }
Example 4
private Object getFieldValueFromColumnValue(Object columnValue, FieldType fieldType) {
    Object result = columnValue;
    if (fieldType == FieldType.CHAR) {
      String columnString = (String) columnValue;
      result = columnString.charAt(0);
    } else if (fieldType == FieldType.DATE) {
      java.sql.Timestamp columnTimestamp = (java.sql.Timestamp) columnValue;
      result = new java.util.Date(columnTimestamp.getTime());
    }
    return result;
  }