@Override public void write(Kryo kryo, Output output, LocalTime object) { final int time = object.getMillisOfDay(); output.writeInt(time, true); final Chronology chronology = object.getChronology(); if (chronology != null && chronology != ISOChronology.getInstanceUTC()) { throw new RuntimeException("Unsupported chronology: " + chronology); } }
@Override public long getLong(int field) { checkState(row != null, "No current row"); Column column = columns.get(field); if (column.getType().getBase() == ColumnType.Base.DATE) { return Days.daysBetween(new LocalDate(0), LocalDate.parse(row.get(column.getPosition()))).getDays(); } if (column.getType().getBase() == ColumnType.Base.TIME) { return LocalTime.parse(row.get(column.getPosition())).getMillisOfDay(); } if (column.getType().getBase() == ColumnType.Base.INTEGER) { return parseInt(row.get(column.getPosition())); } if (column.getType().getBase() == ColumnType.Base.DECIMAL) { DecimalParseResult decimalParseResult = Decimals.parse(row.get(column.getPosition())); return rescale((Long) decimalParseResult.getObject(), decimalParseResult.getType().getScale(), ((DecimalType) columnTypes.get(field)).getScale()); } return parseLong(row.get(column.getPosition())); }
@Override public Object toJdbcType(Object value) { if (value instanceof LocalTime) { return new Time(((LocalTime) value).getMillisOfDay()); } return BasicTypeConverter.toTime(value); }
@Override public void bind(DataBind b, LocalTime value) throws SQLException { if (value == null) { b.setNull(Types.TIME); } else { Time sqlTime = new Time(value.getMillisOfDay()); b.setTime(sqlTime); } }
@Override public Long convert(LocalTime source) { return (long) source.getMillisOfDay(); } }
@Override public Long toNonNullValue(LocalTime value) { return Long.valueOf(value.getMillisOfDay() * 1000000L); } }
@Override public Long toNonNullValue(TimeOfDay value) { return Long.valueOf((value.toLocalTime().getMillisOfDay()) * 1000000L); } }
@Override public Object toJdbcType(Object value) { if (value instanceof LocalTime) { return new Time(((LocalTime) value).getMillisOfDay()); } return BasicTypeConverter.toTime(value); }
@Contract("null -> null; !null -> !null") public static @Nullable Time jodaTimeToSqlTime(final @Nullable LocalTime value) { if (value == null) { return null; } return new Time(value.getMillisOfDay()); }
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException { if (value == null) { StandardBasicTypes.INTEGER.nullSafeSet(preparedStatement, null, index); } else { LocalTime lt = ((LocalTime) value); StandardBasicTypes.INTEGER.nullSafeSet(preparedStatement, new Integer(lt.getMillisOfDay()), index); } }
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException { if (value == null) { StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, null, index); } else { LocalTime lt = ((LocalTime) value); Timestamp timestamp = new Timestamp(lt.getMillisOfDay()); StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, timestamp, index); } }
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException { if (value == null) { StandardBasicTypes.TIME.nullSafeSet(preparedStatement, null, index); } else { LocalTime lt = ((LocalTime) value); Time time = new Time(lt.getMillisOfDay()); StandardBasicTypes.TIME.nullSafeSet(preparedStatement, time, index); } }
@Override public void bind(DataBind b, LocalTime value) throws SQLException { if (value == null) { b.setNull(Types.TIME); } else { Time sqlTime = new Time(value.getMillisOfDay()); b.setTime(sqlTime); } }
@Override public void write(Kryo kryo, Output output, LocalTime object) { final int time = object.getMillisOfDay(); output.writeInt(time, true); final Chronology chronology = object.getChronology(); if (chronology != null && chronology != ISOChronology.getInstanceUTC()) { throw new RuntimeException("Unsupported chronology: " + chronology); } }
@Override public void set(ValueVector v, int index) { if(obj != null){ ((TimeMilliVector) v).setSafe(index, (int) obj.getMillisOfDay()); } }
private java.util.Date getTime(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "a time"); if (!node.isTextual()) { throw new IllegalArgumentException(formatExMsg(path, "is not a time")); } final String textValue = node.getTextValue(); final LocalTime localTime = _HHmmss.parseLocalTime(textValue + "Z"); return new java.util.Date(localTime.getMillisOfDay()); }
public static Duration parseDurationFromTime(String time) { if (StringUtils.isEmpty(time)) { return null; } return Duration.millis(LocalTime.parse(time, new DateTimeFormatterBuilder().appendPattern(TimePattern).toFormatter()).getMillisOfDay()); }
@Override public void write(Kryo kryo, Output output, LocalTime object) { final int time = object.getMillisOfDay(); output.writeInt(time, true); //LocalTime always converts the internal DateTimeZone to UTC so there is no need to serialize it. final String chronologyId = IdentifiableChronology.getChronologyId(object.getChronology()); output.writeString(chronologyId); }
@Override public void write(Kryo kryo, Output output, LocalTime object) { final int time = object.getMillisOfDay(); output.writeInt(time, true); //LocalTime always converts the internal DateTimeZone to UTC so there is no need to serialize it. final String chronologyId = IdentifiableChronology.getChronologyId(object.getChronology()); output.writeString(chronologyId); }
@Test public void testLocalTime() throws Exception { long millis = new LocalTime(session.getStartTime(), DATE_TIME_ZONE).getMillisOfDay(); functionAssertions.assertFunction("LOCALTIME", TimeType.TIME, toTime(millis)); }