/** * {@inheritDoc} */ @Override protected LocalTime parse(String localTimeAsString) { return LocalTime.parse(localTimeAsString); }
/** * {@inheritDoc} */ @Override protected LocalTime parse(String localTimeAsString) { return LocalTime.parse(localTimeAsString); }
@Override protected LocalTime parse(@Nullable final String input) throws Exception { return LocalTime.parse(input); } }
/** * Maps {@code stringValue} to {@code LocalTime}. * * @param stringValue source value as a {@code String} * @return mapped {@code stringValue} to {@code LocalTime} * @see LocalTime#parse(CharSequence) */ public static LocalTime toLocalTime(String stringValue) { return LocalTime.parse(stringValue); }
/** * Parse given string into a LocalTime */ public static LocalTime parseLocalTime(final String value) { return LocalTime.parse(value, formatTime); }
private static LocalTime toLocalTime(final String timestamp) { return LocalTime.parse(timestamp); }
@Override protected LocalTime deserialize(String key, DeserializationContext ctxt) throws IOException { try { return LocalTime.parse(key, DateTimeFormatter.ISO_LOCAL_TIME); } catch (DateTimeException e) { return _handleDateTimeException(ctxt, LocalTime.class, e, key); } }
@Override public LocalTime cast(String src, Class<?> toType, String... args) { // 处理空白 if (Strings.isBlank(src)) return null; return LocalTime.parse(src); } }
@Override protected LocalTime deserialize(String key, DeserializationContext ctxt) throws IOException { try { return LocalTime.parse(key, DateTimeFormatter.ISO_LOCAL_TIME); } catch (DateTimeException e) { return _handleDateTimeException(ctxt, LocalTime.class, e, key); } }
@Override public LocalTime time(final String s) { return format(TIME_FORMAT_PATTERN, s, () -> LocalTime.parse(s, TIME_FORMAT)); }
@Override public LocalTime get(final ResultSet rs, final int index, final int dbSqlType) throws SQLException { if (dbSqlType == Types.VARCHAR) { String string = rs.getString(index); if (string == null) { return null; } return LocalTime.parse(string); } long time = rs.getLong(index); if (time == 0 && rs.wasNull()) { return null; } return LocalTime.ofSecondOfDay(time); } }
@Override public TemporalAccessor parse(String text, Locale locale) throws ParseException { DateTimeFormatter formatterToUse = DateTimeContextHolder.getFormatter(this.formatter, locale); if (LocalDate.class == this.temporalAccessorType) { return LocalDate.parse(text, formatterToUse); } else if (LocalTime.class == this.temporalAccessorType) { return LocalTime.parse(text, formatterToUse); } else if (LocalDateTime.class == this.temporalAccessorType) { return LocalDateTime.parse(text, formatterToUse); } else if (ZonedDateTime.class == this.temporalAccessorType) { return ZonedDateTime.parse(text, formatterToUse); } else if (OffsetDateTime.class == this.temporalAccessorType) { return OffsetDateTime.parse(text, formatterToUse); } else if (OffsetTime.class == this.temporalAccessorType) { return OffsetTime.parse(text, formatterToUse); } else { throw new IllegalStateException("Unsupported TemporalAccessor type: " + this.temporalAccessorType); } }
@Override public LocalTime convert(byte[] source) { return LocalTime.parse(toString(source)); } }
@Override public LocalTime deserialize(JsonParser parser, DeserializationContext context) throws IOException { if (parser.hasToken(JsonToken.VALUE_STRING)) { String string = parser.getText().trim(); if (string.length() == 0) { return null; } return LocalTime.parse(string, _formatter); } throw context.wrongTokenException(parser, JsonToken.START_ARRAY, "Expected array or string."); } }
@Override public TemporalAccessor parse(String text, Locale locale) throws ParseException { DateTimeFormatter formatterToUse = DateTimeContextHolder.getFormatter(this.formatter, locale); if (LocalDate.class == this.temporalAccessorType) { return LocalDate.parse(text, formatterToUse); } else if (LocalTime.class == this.temporalAccessorType) { return LocalTime.parse(text, formatterToUse); } else if (LocalDateTime.class == this.temporalAccessorType) { return LocalDateTime.parse(text, formatterToUse); } else if (ZonedDateTime.class == this.temporalAccessorType) { return ZonedDateTime.parse(text, formatterToUse); } else if (OffsetDateTime.class == this.temporalAccessorType) { return OffsetDateTime.parse(text, formatterToUse); } else if (OffsetTime.class == this.temporalAccessorType) { return OffsetTime.parse(text, formatterToUse); } else { throw new IllegalStateException("Unsupported TemporalAccessor type: " + this.temporalAccessorType); } }
@Override public Object fromString(final String str) { try { return LocalTime.parse(str); } catch (final DateTimeParseException e) { final ConversionException exception = new ConversionException("Cannot parse value as local time", e); exception.add("value", str); throw exception; } }
@Override public LocalTime parse(String value) { if (isMissing(value)) { return null; } value = Strings.padStart(value, 4, '0'); return LocalTime.parse(value, parserFormatter); }
@Override public boolean canParse(String s) { if (isMissing(s)) { return true; } try { LocalTime.parse(s, formatter.withLocale(locale)); return true; } catch (DateTimeParseException e) { // it's all part of the plan return false; } }
/** * Gets the time gap between now and next backup time. * * @return the time gap to next backup */ private long getTimeToNextBackup() { LocalDateTime now = LocalDateTime.now(Clock.systemUTC()); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("H:mm"); LocalTime backupTime = LocalTime.parse(ServerConfiguration .get(PropertyKey.MASTER_DAILY_BACKUP_TIME), formatter); LocalDateTime nextBackupTime = now.withHour(backupTime.getHour()) .withMinute(backupTime.getMinute()); if (nextBackupTime.isBefore(now)) { nextBackupTime = nextBackupTime.plusDays(1); } return ChronoUnit.MILLIS.between(now, nextBackupTime); }
void updateValue() { if (is24HourView) { LocalTimeStringConverter localTimeStringConverter = new LocalTimeStringConverter(FormatStyle.SHORT, Locale.GERMAN); timePicker.setValue(localTimeStringConverter.fromString(selectedHourLabel.getText() + ":" + selectedMinLabel.getText())); } else { timePicker.setValue(LocalTime.parse(selectedHourLabel.getText() + ":" + selectedMinLabel.getText() + " " + period.get(), DateTimeFormatter.ofPattern("h:mm a").withLocale(Locale.ENGLISH))); } }