@Override public void set(final PreparedStatement st, final int index, final LocalTime value, final int dbSqlType) throws SQLException { if (value == null) { st.setNull(index, dbSqlType); return; } if (dbSqlType == Types.VARCHAR) { st.setString(index, value.toString()); return; } st.setLong(index, value.toSecondOfDay()); }
@Override public byte[] convert(LocalTime source) { return fromString(source.toString()); } }
LocalTime time = new LocalTime(12, 20); String formatted = time.toString("HH:mm");
public static String formatRollTime(final LocalTime time, final ZoneId zoneId) { return String.format("%s;%s;%s", Type.ROLL_TIME.name(), time.toString(), zoneId.toString()); }
@Override public void stringifyValue(StringBuilder buffer, int row) { if (isRepeating) { row = 0; } if (noNulls || !isNull[row]) { scratchTimestamp.setTime(time[row]); scratchTimestamp.setNanos(nanos[row]); if (isUTC) { LocalDateTime ts = LocalDateTime.ofInstant(Instant.ofEpochMilli(time[row]), ZoneOffset.UTC).withNano(nanos[row]); buffer.append(ts.toLocalDate().toString() + ' ' + ts.toLocalTime().toString()); } else { buffer.append(scratchTimestamp.toString()); } } else { buffer.append("null"); } }
public static QueueOffsetSpec ofRollTime(final LocalTime time, final ZoneId zoneId) { return new QueueOffsetSpec(Type.ROLL_TIME, new String[]{time.toString(), zoneId.toString()}); }
System.out.println("LocalTime : " + localTime.toString()); System.out.println("localDate : " + localDate.toString()); System.out.println("dateTime : " + dateTime.toString());
@Override public void writeLocalTime( LocalTime localTime ) throws RuntimeException { append( "{localTime: " ); append( quote( localTime.toString() ) ); append( "}" ); }
/** * Returns a DateTime column where each value consists of the dates from this column combined with the corresponding * times from the other column */ default DateTimeColumn atTime(LocalTime time) { Preconditions.checkNotNull(time); DateTimeColumn newColumn = DateTimeColumn.create(this.name() + " " + time.toString()); for (int r = 0; r < this.size(); r++) { int c1 = this.getIntInternal(r); if (DateColumn.valueIsMissing(c1)) { newColumn.appendMissing(); } else { LocalDate value1 = PackedLocalDate.asLocalDate(c1); newColumn.appendInternal(PackedLocalDateTime.pack(value1, time)); } } return newColumn; }
@Override public String formatValue(LocalTime v) { return v.toString(); }
int millis = 5000; int seconds = millis / 1000; // Maybe no need to divide if the input is in seconds LocalTime timeOfDay = LocalTime.ofSecondOfDay(seconds); String time = timeOfDay.toString();
@Override public void jsonWrite(JsonGenerator writer, LocalTime value) throws IOException { writer.writeString(value.toString()); }
Assert.assertThat(withJoda.getT().toString(), is(withJsr310.getT().toString())); Assert.assertThat(withJoda.getTs().toString(), is(withJsr310.getTs().toString())); Assert.assertThat(withJoda.getDec(), comparesEqualTo(withJsr310.getDec()));
@Override public String toString(LocalTime value) { if (value != null) { return value.toString(); } return null; } }
public class MyLocalTimeSerializer extends JsonSerializer<LocalDate> { @Override public void serialize( LocalTime time, JsonGenerator gen, SerializerProvider arg2) throws IOException, JsonProcessingException { gen.writeString(time.toString("HH:mm")); } }
@Override public void set(final PreparedStatement st, final int index, final LocalTime value, final int dbSqlType) throws SQLException { if (value == null) { st.setNull(index, dbSqlType); return; } if (dbSqlType == Types.VARCHAR) { st.setString(index, value.toString()); return; } st.setLong(index, value.toSecondOfDay()); }
@Override public void encode(BsonWriter writer, LocalTime value, EncoderContext encoderContext) { writer.writeString(value.toString()); }
LocalTime start = LocalTime.parse( "08:00" ); int hours = 2; LocalTime time = start; for ( int i = 0 ; i <= hours ; i++ ) { String output = time.toString(); // Set up next loop. time = time.plusHours( 1 ); }
@Override public byte[] convert(LocalTime source) { return fromString(source.toString()); } }
/** * Outputs this date-time as a {@code String}. * <p> * The output will include the full local date-time and the chronology ID. * * @return a string representation of this date-time, not null */ @Override public String toString() { return toLocalDate().toString() + 'T' + toLocalTime().toString(); }