本文整理了Java中java.sql.Date.from()
方法的一些代码示例,展示了Date.from()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Date.from()
方法的具体详情如下:
包路径:java.sql.Date
类名称:Date
方法名:from
暂无
代码示例来源:origin: AxonFramework/AxonFramework
private static Trigger buildTrigger(Instant triggerDateTime, JobKey key) {
return TriggerBuilder.newTrigger()
.forJob(key)
.startAt(Date.from(triggerDateTime))
.build();
}
代码示例来源:origin: hibernate/hibernate-orm
return (X) java.sql.Date.from( instant );
代码示例来源:origin: hibernate/hibernate-orm
@Override
@SuppressWarnings("unchecked")
public <X> X unwrap(ZonedDateTime zonedDateTime, Class<X> type, WrapperOptions options) {
if ( zonedDateTime == null ) {
return null;
}
if ( ZonedDateTime.class.isAssignableFrom( type ) ) {
return (X) zonedDateTime;
}
if ( Calendar.class.isAssignableFrom( type ) ) {
return (X) GregorianCalendar.from( zonedDateTime );
}
if ( Timestamp.class.isAssignableFrom( type ) ) {
return (X) Timestamp.from( zonedDateTime.toInstant() );
}
if ( java.sql.Date.class.isAssignableFrom( type ) ) {
return (X) java.sql.Date.from( zonedDateTime.toInstant() );
}
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
return (X) java.sql.Time.from( zonedDateTime.toInstant() );
}
if ( Date.class.isAssignableFrom( type ) ) {
return (X) Date.from( zonedDateTime.toInstant() );
}
if ( Long.class.isAssignableFrom( type ) ) {
return (X) Long.valueOf( zonedDateTime.toInstant().toEpochMilli() );
}
throw unknownUnwrap( type );
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
@SuppressWarnings("unchecked")
public <X> X unwrap(Instant instant, Class<X> type, WrapperOptions options) {
if ( instant == null ) {
return null;
}
if ( Instant.class.isAssignableFrom( type ) ) {
return (X) instant;
}
if ( Calendar.class.isAssignableFrom( type ) ) {
final ZoneId zoneId = ZoneId.ofOffset( "UTC", ZoneOffset.UTC );
return (X) GregorianCalendar.from( instant.atZone( zoneId ) );
}
if ( java.sql.Timestamp.class.isAssignableFrom( type ) ) {
return (X) Timestamp.from( instant );
}
if ( java.sql.Date.class.isAssignableFrom( type ) ) {
return (X) java.sql.Date.from( instant );
}
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
return (X) java.sql.Time.from( instant );
}
if ( java.util.Date.class.isAssignableFrom( type ) ) {
return (X) Date.from( instant );
}
if ( Long.class.isAssignableFrom( type ) ) {
return (X) Long.valueOf( instant.toEpochMilli() );
}
throw unknownUnwrap( type );
}
代码示例来源:origin: oracle/opengrok
out.write(Util.encode(m.getMessage().getCssClass()));
out.write("\" title=\"Expires on ");
out.write(Util.encode(df.format(Date.from(m.getExpirationTime()))));
out.write("\">");
out.write(Util.encode(df.format(Date.from(m.getAcceptedTime()))));
out.write(": ");
out.write(m.getMessage().getText());
代码示例来源:origin: hibernate/hibernate-orm
@Override
@SuppressWarnings("unchecked")
public <X> X unwrap(OffsetDateTime offsetDateTime, Class<X> type, WrapperOptions options) {
if ( offsetDateTime == null ) {
return null;
}
if ( OffsetDateTime.class.isAssignableFrom( type ) ) {
return (X) offsetDateTime;
}
if ( Calendar.class.isAssignableFrom( type ) ) {
return (X) GregorianCalendar.from( offsetDateTime.toZonedDateTime() );
}
if ( Timestamp.class.isAssignableFrom( type ) ) {
return (X) Timestamp.from( offsetDateTime.toInstant() );
}
if ( java.sql.Date.class.isAssignableFrom( type ) ) {
return (X) java.sql.Date.from( offsetDateTime.toInstant() );
}
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
return (X) java.sql.Time.from( offsetDateTime.toInstant() );
}
if ( Date.class.isAssignableFrom( type ) ) {
return (X) Date.from( offsetDateTime.toInstant() );
}
if ( Long.class.isAssignableFrom( type ) ) {
return (X) Long.valueOf( offsetDateTime.toInstant().toEpochMilli() );
}
throw unknownUnwrap( type );
}
代码示例来源:origin: apache/nifi
final DateTimeFormatter dtFormatter = getDateTimeFormatter(valueFormat);
LocalDate parsedDate = LocalDate.parse(parameterValue, dtFormatter);
date = new java.sql.Date(java.sql.Date.from(parsedDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()).getTime());
代码示例来源:origin: oblac/jodd
assertEquals(Date.from(instant), email.sentDate());
代码示例来源:origin: palantir/atlasdb
private RetryableException retryable(Throwable ex) {
return new RetryableException("", ex, Date.from(Instant.EPOCH));
}
代码示例来源:origin: com.github.rutledgepaulv/q-builders
@Override
public Object apply(Object o) {
if(o instanceof Instant) {
return Date.from((Instant) o);
}
return o;
}
代码示例来源:origin: com.github.jcustenborder/vertica-stream-writer
@Override
protected long utcTime(ZonedDateTime input) {
return Date.from(input.toInstant()).getTime();
}
}
代码示例来源:origin: jcustenborder/kafka-connect-spooldir
@Override
protected Object convert(Object input) {
final LocalDate localDate = (LocalDate) input;
final Instant instant = localDate.atStartOfDay(ZONE_ID).toInstant();
return Date.from(instant);
}
代码示例来源:origin: exoplatform/platform
public static Calendar parseDateBase64(String dateString) {
try {
dateString = new String(Base64.decodeBase64(dateString.getBytes()));
Calendar calendar = Calendar.getInstance();
Instant instant = LocalDate.parse(dateString, dateFormat).atStartOfDay().atZone(ZoneId.systemDefault()).toInstant();
calendar.setTime(Date.from(instant));
return calendar;
} catch (Exception exception) {
throw new RuntimeException(exception);
}
}
代码示例来源:origin: apache/archiva
@Override
public void updateTimestamp(boolean save, ZonedDateTime time) throws IOException {
delegate.updateTimestamp(save, Date.from(time.toInstant()));
}
代码示例来源:origin: org.axonframework/axon-core
private static Set<Trigger> buildTrigger(Instant triggerDateTime, JobKey key) {
return Collections.singleton(TriggerBuilder.newTrigger()
.forJob(key)
.startAt(Date.from(triggerDateTime))
.build());
}
}
代码示例来源:origin: org.axonframework/axon-messaging
private static Trigger buildTrigger(Instant triggerDateTime, JobKey key) {
return TriggerBuilder.newTrigger()
.forJob(key)
.startAt(Date.from(triggerDateTime))
.build();
}
代码示例来源:origin: kaif-open/kaif
public V1VoteDto toV1Dto() {
return new V1VoteDto(articleId.toString(), voteState, Date.from(updateTime));
}
}
代码示例来源:origin: jcustenborder/kafka-connect-spooldir
@Override
protected Object convert(Object input) {
final LocalTime localTime = (LocalTime) input;
final Instant instant = localTime.atDate(EPOCH_DATE).toInstant(ZoneOffset.UTC);
return Date.from(instant);
}
代码示例来源:origin: kaif-open/kaif
public V1ArticleDto toV1Dto() {
return new V1ArticleDto(zone.value(),
aliasName,
articleId.toString(),
title,
link,
content,
isExternalLink() ? V1ArticleType.EXTERNAL_LINK : V1ArticleType.SPEAK,
Date.from(createTime),
authorName,
upVote,
debateCount,
deleted);
}
代码示例来源:origin: com.opencredo/concourse-cassandra
private Object[] getBindArguments(Event event) {
return new Object[] {
event.getAggregateId().getType(),
event.getAggregateId().getId(),
Date.from(event.getEventTimestamp().getTimestamp()),
event.getEventTimestamp().getStreamId(),
event.getProcessingId().orElseThrow(() -> new IllegalArgumentException("Event has no processing id")),
event.getEventName().getName(),
event.getEventName().getVersion(),
event.getParameters().serialise(serialiser),
event.getCharacteristics()
};
}
内容来源于网络,如有侵权,请联系作者删除!