@Override public Timestamp getTimestamp(int columnIndex) { return getCurrentRowAsStruct().getTimestamp(columnIndex); }
return Value.date(value.getDate(fieldIndex)); case TIMESTAMP: return Value.timestamp(value.getTimestamp(fieldIndex)); case STRUCT: return Value.struct(value.getStruct(fieldIndex));
builder.set(field, nullValue ? null : row.getString(fieldName)); } else if (spannerType.equals("TIMESTAMP")) { builder.set(field, nullValue ? null : row.getTimestamp(fieldName).toString()); } else if (spannerType.equals("DATE")) { builder.set(field, nullValue ? null : row.getDate(fieldName).toString());
@Override public Timestamp getTimestamp(String columnName) { return getCurrentRowAsStruct().getTimestamp(columnName); }
return Value.date(value.getDate(fieldIndex)); case TIMESTAMP: return Value.timestamp(value.getTimestamp(fieldIndex)); case STRUCT: return Value.struct(value.getStruct(fieldIndex));
@Test public void bindTimestamp() { Timestamp t = Timestamp.parseTimestamp("2016-09-18T00:00:00Z"); Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").to(t), Type.timestamp()); assertThat(row.isNull(0)).isFalse(); assertThat(row.getTimestamp(0)).isEqualTo(t); }
@Test public void writeCommitTimestamp() { Timestamp commitTimestamp = write(baseInsert().set("TimestampValue").to(Value.COMMIT_TIMESTAMP).build()); Struct row = readLastRow("TimestampValue"); assertThat(row.getTimestamp(0)).isEqualTo(commitTimestamp); }
@Test public void writeTimestamp() { Timestamp timestamp = Timestamp.parseTimestamp("2016-09-15T00:00:00.111111Z"); write(baseInsert().set("TimestampValue").to(timestamp).build()); Struct row = readLastRow("TimestampValue"); assertThat(row.isNull(0)).isFalse(); assertThat(row.getTimestamp(0)).isEqualTo(timestamp); }
@Override public Timestamp getTimestamp(int columnIndex) { return getCurrentRowAsStruct().getTimestamp(columnIndex); }
@Override public Timestamp getTimestamp(String columnName) { return getCurrentRowAsStruct().getTimestamp(columnName); }
case TIMESTAMP: return nullSafeColumnParser( (currentRow, columnName) -> currentRow.getTimestamp(columnName).toString()); case ARRAY: return nullSafeColumnParser(SpannerConverters::parseArrayValue);