本文整理了Java中java.time.LocalTime.from()
方法的一些代码示例,展示了LocalTime.from()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalTime.from()
方法的具体详情如下:
包路径:java.time.LocalTime
类名称:LocalTime
方法名:from
[英]Obtains an instance of LocalTime from a temporal object.
A TemporalAccessor represents some form of date and time information. This factory converts the arbitrary temporal object to an instance of LocalTime.
The conversion uses the TemporalQueries#localTime() query, which relies on extracting the ChronoField#NANO_OF_DAY field.
This method matches the signature of the functional interface TemporalQueryallowing it to be used in queries via method reference, LocalTime::from.
[中]从时态对象获取LocalTime的实例。
临时助理表示某种形式的日期和时间信息。此工厂将任意时态对象转换为LocalTime实例。
转换使用TemporalQueries#localTime()查询,该查询依赖于提取ChronoField#NANO_OF_DAY字段。
此方法匹配函数接口TemporalQueryLow的签名,通过方法引用LocalTime::from将其用于查询。
代码示例来源:origin: prontera/spring-cloud-rest-tcc
@Override
public LocalTime convertFrom(LocalTime localTime, Type<LocalTime> type, MappingContext mappingContext) {
return LocalTime.from(localTime);
}
}
代码示例来源:origin: prontera/spring-cloud-rest-tcc
@Override
public LocalTime convertTo(LocalTime localTime, Type<LocalTime> type, MappingContext mappingContext) {
return LocalTime.from(localTime);
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public LocalTime fromString(String string) {
return LocalTime.from( LocalTimeType.FORMATTER.parse( string ) );
}
代码示例来源:origin: debezium/debezium
/**
* Converts a string object for an object type of {@link Duration}.
*
* @param column the column definition describing the {@code data} value; never null
* @param value the string object to be converted into a {@link Duration} type;
* @return the converted value;
*/
private Object convertToDuration(Column column, String value) {
return Duration.between(LocalTime.MIN, LocalTime.from(timeFormat(column.length()).parse(value)));
}
代码示例来源:origin: apache/ignite
/**
* Copy constructor.
*
* @param entity Entity to copy from.
*/
EntityWithDateTimeFields(EntityWithDateTimeFields entity) {
id = entity.id;
locTime = LocalTime.from(entity.locTime);
locDate = LocalDate.from(entity.locDate);
locDateTime = LocalDateTime.from(entity.locDateTime);
}
代码示例来源:origin: apache/hive
ZoneId zoneId;
try {
localTime = LocalTime.from(accessor);
} catch (DateTimeException e1) {
localTime = DEFAULT_LOCAL_TIME;
代码示例来源:origin: debezium/debezium
assertThat(schemaG.defaultValue()).isEqualTo(date);
Duration duration1 = Duration.between(LocalTime.MIN, LocalTime.from(DateTimeFormatter.ofPattern("HH:mm:ss.S").parse("23:00:00.7")));
assertThat(schemaH.defaultValue()).isEqualTo(new java.util.Date(io.debezium.time.Time.toMilliOfDay(duration1, MySqlValueConverters::adjustTemporal)));
Duration duration2 = Duration.between(LocalTime.MIN, LocalTime.from(DateTimeFormatter.ofPattern("HH:mm:ss.SSSSSS").parse("23:00:00.123456")));
assertThat(schemaI.defaultValue()).isEqualTo(new java.util.Date(io.debezium.time.Time.toMilliOfDay(duration2, MySqlValueConverters::adjustTemporal)));
assertEmptyFieldValue(record, "K");
代码示例来源:origin: embulk/embulk
timeFromDefault = LocalTime.from(given);
} else {
if (given.isSupported(ChronoField.NANO_OF_DAY)) {
代码示例来源:origin: org.apache.wicket/wicket-util
@Override
protected LocalTime createTemporal(TemporalAccessor temporalAccessor)
{
return LocalTime.from(temporalAccessor);
}
代码示例来源:origin: com.github.seratch/java-time-backport
@Override
public LocalTime queryFrom(TemporalAccessor temporal) {
return LocalTime.from(temporal);
}
};
代码示例来源:origin: com.github.almex/raildelays-api
/**
* Initialization constructor.
*
* @param expectedTime the expected time such as : 1st January 2000 at 12:00
* @param delay delay in milliseconds counting from the {@code expectedTime}
*/
private TimeDelay(LocalTime expectedTime, Long delay) {
this.expectedTime = LocalTime.from(expectedTime);
this.delay = delay != null ? delay : DEFAULT_DELAY;
}
代码示例来源:origin: wmixvideo/nfe
@Override
public LocalTime read(final String time) {
return LocalTime.from(DateTimeFormatter.ofPattern("HH:mm:ss").parse(time));
}
代码示例来源:origin: wmixvideo/nfe
@Override
public LocalTime read(final String time) {
return LocalTime.from(DateTimeFormatter.ofPattern("HH:mm:ss").parse(time));
}
代码示例来源:origin: kiegroup/droolsjbpm-knowledge
@Override
public LocalTime unmarshal( String localTimeString ) throws Exception {
if ( localTimeString == null ) {
return null;
}
try {
return LocalTime.from( formatter.parse( localTimeString ) );
} catch ( DateTimeException e ) {
throw new IllegalStateException( "Failed to convert string (" + localTimeString + ") to type ("
+ LocalTime.class.getName() + ")." );
}
}
代码示例来源:origin: org.tiogasolutions.dev/tioga-dev-common
public LocalTime toLocalTime(long date) {
if (date == 0) {
return null;
} else if (date > 0) {
Instant instant = Instant.ofEpochMilli(date);
return LocalTime.from(instant.atZone(zoneId));
} else {
throw new IllegalArgumentException("The value \"date\" must be greater than or equal to zero.");
}
}
public LocalTime toLocalTime(java.util.Date date) {
代码示例来源:origin: org.kie.soup/kie-soup-commons
@Override
public Object unmarshal( HierarchicalStreamReader reader, UnmarshallingContext context ) {
String localTimeString = reader.getValue();
try {
return LocalTime.from( formatter.parse( localTimeString ) );
} catch ( DateTimeException e ) {
throw new IllegalStateException( "Failed to convert string (" + localTimeString + ") to type ("
+ LocalTime.class.getName() + ")." );
}
}
代码示例来源:origin: icode/ameba
@Override
public LocalTime fromString(String value) {
if (value == null) {
throw new IllegalArgumentException(
LocalizationMessages.METHOD_PARAMETER_CANNOT_BE_NULL("value")
);
}
return LocalTime.from(parseInstant(value));
}
代码示例来源:origin: org.n52.wps/engine
@Override
public LocalTime parse(String value) throws DecodingException {
try {
return LocalTime.from(DateTimeFormatter.ISO_TIME.parse(value));
} catch (DateTimeException ex) {
throw new DecodingException(ex);
}
}
代码示例来源:origin: com.impossibl.pgjdbc-ng/pgjdbc-ng
@Override
protected Object decodeValue(Context context, Type type, Short typeLength, Integer typeModifier, CharSequence buffer, Class<?> targetClass, Object targetContext) throws IOException {
Calendar calendar = targetContext != null ? (Calendar) targetContext : Calendar.getInstance();
TemporalAccessor parsed = context.getTimeFormat().getParser().parse(buffer);
LocalTime time = LocalTime.from(parsed);
return convertOutput(context, type, time, targetClass, calendar);
}
代码示例来源:origin: org.hibernate.orm/hibernate-core
public static SqmLiteralTime from(String literalText, SqmCreationContext creationContext) {
final LocalTime localTime = LocalTime.from( JdbcTimeJavaDescriptor.FORMATTER.parse( literalText ) );
final Time literal = Time.valueOf( localTime );
return new SqmLiteralTime(
literal,
creationContext.getSessionFactory().getTypeConfiguration().getBasicTypeRegistry().getBasicType( Time.class )
);
}
内容来源于网络,如有侵权,请联系作者删除!