use of php.runtime.ext.core.classes.time.WrapTime in project jphp by jphp-compiler.
the class UXMaterialTimePicker method getValueAsTime.
@Getter
public WrapTime getValueAsTime(Environment env) {
initFormat();
LocalTime value = getWrappedObject().getValue();
if (value == null) {
return null;
}
Instant instant = value.atDate(LocalDate.of(0, 0, 0)).atZone(ZoneId.systemDefault()).toInstant();
return new WrapTime(env, Date.from(instant));
}
use of php.runtime.ext.core.classes.time.WrapTime in project jphp by jphp-compiler.
the class PSqlStatement method bind.
@Signature
public void bind(Environment env, int index, Memory value) throws SQLException {
if (value.instanceOf(WrapTime.class)) {
WrapTime time = value.toObject(WrapTime.class);
statement.setDate(index + 1, new Date(time.getDate().getTime()), time.getCalendar());
} else if (value.instanceOf(Stream.class)) {
statement.setBlob(index + 1, Stream.getInputStream(env, value));
} else if (value.toValue() instanceof BinaryMemory) {
statement.setBytes(index + 1, value.getBinaryBytes(env.getDefaultCharset()));
} else {
if (value.isNull()) {
statement.setNull(index + 1, Types.NULL);
} else {
switch(value.getRealType()) {
case INT:
statement.setLong(index + 1, value.toLong());
break;
case DOUBLE:
statement.setDouble(index + 1, value.toDouble());
break;
case BOOL:
statement.setBoolean(index + 1, value.toBoolean());
break;
default:
statement.setString(index + 1, value.toString());
}
}
}
}
use of php.runtime.ext.core.classes.time.WrapTime in project jphp by jphp-compiler.
the class PSqlStatement method bindTimestamp.
@Signature
public void bindTimestamp(Environment env, int index, Memory value) throws SQLException {
if (value.instanceOf(WrapTime.class)) {
WrapTime time = value.toObject(WrapTime.class);
statement.setTimestamp(index + 1, new Timestamp(time.getDate().getTime()), time.getCalendar());
} else {
statement.setTimestamp(index + 1, new Timestamp(value.toLong()));
}
}
use of php.runtime.ext.core.classes.time.WrapTime in project jphp by jphp-compiler.
the class UXDatePicker method getValueAsTime.
@Getter
public WrapTime getValueAsTime(Environment env) {
initFormat();
LocalDate value = getWrappedObject().getValue();
if (value == null) {
return null;
}
return new WrapTime(env, Date.from(value.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()));
}
use of php.runtime.ext.core.classes.time.WrapTime in project jphp by jphp-compiler.
the class PSqlResult method getTyped.
public Memory getTyped(Environment env, int index) throws SQLException {
index += 1;
ResultSet set = resultSet;
int type = metaData.getColumnType(index);
if (set.getObject(index) == null) {
return Memory.NULL;
}
switch(type) {
case Types.INTEGER:
case Types.SMALLINT:
case Types.TINYINT:
case Types.BIT:
return LongMemory.valueOf(set.getLong(index));
case Types.BOOLEAN:
return TrueMemory.valueOf(set.getBoolean(index));
case Types.FLOAT:
case Types.DOUBLE:
case Types.DECIMAL:
return DoubleMemory.valueOf(set.getDouble(index));
case Types.NULL:
return Memory.NULL;
case Types.TIME:
Time time = set.getTime(index);
return ObjectMemory.valueOf(new WrapTime(env, time));
case Types.TIMESTAMP:
Timestamp timestamp = set.getTimestamp(index);
return ObjectMemory.valueOf(new WrapTime(env, timestamp));
case Types.DATE:
Date date = set.getDate(index);
return ObjectMemory.valueOf(new WrapTime(env, date));
case Types.VARCHAR:
case Types.LONGVARCHAR:
case Types.CHAR:
case Types.BIGINT:
return StringMemory.valueOf(set.getString(index));
case Types.NVARCHAR:
case Types.LONGNVARCHAR:
return StringMemory.valueOf(set.getNString(index));
case Types.BINARY:
return new BinaryMemory(set.getBytes(index));
case Types.BLOB:
case Types.CLOB:
case Types.NCLOB:
try {
Blob blob = set.getBlob(index);
return ObjectMemory.valueOf(new MiscStream(env, blob.getBinaryStream()));
} catch (SQLException e) {
return new BinaryMemory(set.getBytes(index));
}
default:
return StringMemory.valueOf(set.getString(index));
}
}
Aggregations