本文整理了Java中java.time.LocalTime.parse()
方法的一些代码示例,展示了LocalTime.parse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalTime.parse()
方法的具体详情如下:
包路径:java.time.LocalTime
类名称:LocalTime
方法名:parse
[英]Obtains an instance of LocalTime from a text string such as 10:15.
The string must represent a valid time and is parsed using java.time.format.DateTimeFormatters#isoLocalTime().
[中]从文本字符串(如10:15)获取LocalTime的实例。
字符串必须表示有效时间,并使用java解析。时间总体安排DateTimeFormatters#isoLocalTime()。
代码示例来源:origin: org.assertj/assertj-core
/**
* {@inheritDoc}
*/
@Override
protected LocalTime parse(String localTimeAsString) {
return LocalTime.parse(localTimeAsString);
}
代码示例来源:origin: joel-costigliola/assertj-core
/**
* {@inheritDoc}
*/
@Override
protected LocalTime parse(String localTimeAsString) {
return LocalTime.parse(localTimeAsString);
}
代码示例来源:origin: dropwizard/dropwizard
@Override
protected LocalTime parse(@Nullable final String input) throws Exception {
return LocalTime.parse(input);
}
}
代码示例来源:origin: oracle/helidon
/**
* 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);
}
代码示例来源:origin: apache/drill
/**
* Parse given string into a LocalTime
*/
public static LocalTime parseLocalTime(final String value) {
return LocalTime.parse(value, formatTime);
}
代码示例来源:origin: OpenHFT/Chronicle-Queue
private static LocalTime toLocalTime(final String timestamp) {
return LocalTime.parse(timestamp);
}
代码示例来源:origin: prestodb/presto
@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);
}
}
代码示例来源:origin: nutzam/nutz
@Override
public LocalTime cast(String src, Class<?> toType, String... args) {
// 处理空白
if (Strings.isBlank(src))
return null;
return LocalTime.parse(src);
}
}
代码示例来源:origin: com.fasterxml.jackson.datatype/jackson-datatype-jsr310
@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);
}
}
代码示例来源:origin: debezium/debezium
@Override
public LocalTime time(final String s) {
return format(TIME_FORMAT_PATTERN, s, () -> LocalTime.parse(s, TIME_FORMAT));
}
代码示例来源:origin: oblac/jodd
@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);
}
}
代码示例来源:origin: spring-projects/spring-framework
@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);
}
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public LocalTime convert(byte[] source) {
return LocalTime.parse(toString(source));
}
}
代码示例来源:origin: bootique/bootique
@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.");
}
}
代码示例来源:origin: org.springframework/spring-context
@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);
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
@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;
}
}
代码示例来源:origin: jtablesaw/tablesaw
@Override
public LocalTime parse(String value) {
if (isMissing(value)) {
return null;
}
value = Strings.padStart(value, 4, '0');
return LocalTime.parse(value, parserFormatter);
}
代码示例来源:origin: jtablesaw/tablesaw
@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;
}
}
代码示例来源:origin: Alluxio/alluxio
/**
* 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);
}
代码示例来源:origin: jfoenixadmin/JFoenix
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)));
}
}
内容来源于网络,如有侵权,请联系作者删除!