本文整理了Java中org.joda.time.Instant.toDate()
方法的一些代码示例,展示了Instant.toDate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instant.toDate()
方法的具体详情如下:
包路径:org.joda.time.Instant
类名称:Instant
方法名:toDate
[英]Get this object as a DateTime using ISOChronology in the default zone.
This method returns a DateTime object in the default zone. This differs from the similarly named method on DateTime, DateMidnight or MutableDateTime which retains the time zone. The difference is because Instant really represents a time without a zone, thus calling this method we really have no zone to 'retain' and hence expect to switch to the default zone.
This method definition preserves compatibility with earlier versions of Joda-Time.
[中]使用默认区域中的等时方法获取此对象作为日期时间。
此方法返回默认区域中的DateTime对象。这与保留时区的DateTime、DateMidnight或MutableDateTime上类似命名的方法不同。区别在于Instant实际上表示一个没有区域的时间,因此调用此方法时,我们实际上没有要“保留”的区域,因此希望切换到默认区域。
此方法定义保留了与Joda Time早期版本的兼容性。
代码示例来源:origin: objectify/objectify
@Override
protected Value<Timestamp> saveValue(final ReadableInstant value, final SaveContext ctx, final Path path) throws SkipException {
return TimestampValue.of(Timestamp.of(value.toInstant().toDate()));
}
};
代码示例来源:origin: arnaudroger/SimpleFlatMapper
@Override
public Date convert(Instant in, Context context) throws Exception {
if (in == null) return null;
return in.toDate();
}
}
代码示例来源:origin: br.com.anteros/Anteros-Persistence-Core
public Date convertToDatabaseColumn(Instant instant) {
return instant.toDate();
}
代码示例来源:origin: stackoverflow.com
Instant instant = ...;
Date date = instant.toDate();
instant = new Instant(date);
// Or...
instant = new Instant(date.getTime());
代码示例来源:origin: com.googlecode.cedar-common/objectify
@Override
public Object forDatastore(Object value, ConverterSaveContext ctx)
{
if (value instanceof ReadableInstant)
return ((ReadableInstant)value).toInstant().toDate();
else
return null;
}
代码示例来源:origin: com.threewks.thundr/thundr
@Override
public Date from(ReadableInstant from) {
return from == null ? null : from.toInstant().toDate();
}
代码示例来源:origin: 3wks/thundr
@Override
public Date from(ReadableInstant from) {
return from == null ? null : from.toInstant().toDate();
}
代码示例来源:origin: Netflix/metacat
/**
* Insert.
*/
@PrePersist
public void onInsert() {
if (createdDate == null) {
setCreatedDate(Instant.now().toDate());
}
if (lastUpdatedDate == null) {
setLastUpdatedDate(Instant.now().toDate());
}
}
代码示例来源:origin: timolson/cointrader
public Temporal(Instant time) {
super();
this.id = getId();
this.time = time;
this.dateTime = time.toDate();
this.timestamp = time.getMillis();
this.updateTime = new AtomicReference<Instant>(time);
this.updateTimestamp = new AtomicLong(time.getMillis());
}
代码示例来源:origin: com.netflix.metacat/metacat-s3-connector
/**
* Insert.
*/
@PrePersist
public void onInsert() {
setCreatedDate(Calendar.getInstance().getTime());
setLastUpdatedDate(Instant.now().toDate());
}
代码示例来源:origin: JodaOrg/joda-time-hibernate
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException {
if (value == null) {
StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, null, index);
} else {
StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, ((Instant) value).toDate(), index);
}
}
代码示例来源:origin: joda-time/joda-time-hibernate
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException {
if (value == null) {
StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, null, index);
} else {
StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, ((Instant) value).toDate(), index);
}
}
代码示例来源:origin: powertac/powertac-server
@SuppressWarnings("deprecation")
public static void setDaysOfWeek ()
{
Instant base = Competition.currentCompetition().getSimulationBaseTime();
int bias = Math.abs(base.toDate().getDay() - DAYS_OF_WEEK) % DAYS_OF_WEEK;
MONDAY = (MONDAY + bias) % DAYS_OF_WEEK;
TUESDAY = (TUESDAY + bias) % DAYS_OF_WEEK;
WEDNESDAY = (WEDNESDAY + bias) % DAYS_OF_WEEK;
THURSDAY = (THURSDAY + bias) % DAYS_OF_WEEK;
FRIDAY = (FRIDAY + bias) % DAYS_OF_WEEK;
SATURDAY = (SATURDAY + bias) % DAYS_OF_WEEK;
SUNDAY = (SUNDAY + bias) % DAYS_OF_WEEK;
}
代码示例来源:origin: powertac/powertac-server
@SuppressWarnings("deprecation")
public static void setDaysOfWeek ()
{
Instant base = Competition.currentCompetition().getSimulationBaseTime();
int bias = Math.abs(base.toDate().getDay() - DAYS_OF_WEEK) % DAYS_OF_WEEK;
MONDAY = (MONDAY + bias) % DAYS_OF_WEEK;
TUESDAY = (TUESDAY + bias) % DAYS_OF_WEEK;
WEDNESDAY = (WEDNESDAY + bias) % DAYS_OF_WEEK;
THURSDAY = (THURSDAY + bias) % DAYS_OF_WEEK;
FRIDAY = (FRIDAY + bias) % DAYS_OF_WEEK;
SATURDAY = (SATURDAY + bias) % DAYS_OF_WEEK;
SUNDAY = (SUNDAY + bias) % DAYS_OF_WEEK;
}
}
代码示例来源:origin: Netflix/metacat
@PreUpdate
void onUpdate() {
if (lastUpdatedDate == null) {
setLastUpdatedDate(Instant.now().toDate());
}
}
代码示例来源:origin: timolson/cointrader
protected synchronized void setTime(Instant time) {
this.time = time;
this.dateTime = time.toDate();
this.time = time;
setUpdateTime(time);
setTimestamp(time.getMillis());
}
代码示例来源:origin: com.netflix.metacat/metacat-s3-connector
@PreUpdate
void onUpdate() {
setLastUpdatedDate(Instant.now().toDate());
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-io-kinesis
GetMetricStatisticsRequest createMetricStatisticsRequest(
String streamName, Instant countSince, Instant countTo, Minutes period) {
return new GetMetricStatisticsRequest()
.withNamespace(KINESIS_NAMESPACE)
.withMetricName(INCOMING_RECORDS_METRIC)
.withPeriod(period.getMinutes() * PERIOD_GRANULARITY_IN_SECONDS)
.withStartTime(countSince.toDate())
.withEndTime(countTo.toDate())
.withStatistics(Collections.singletonList(SUM_STATISTIC))
.withDimensions(
Collections.singletonList(
new Dimension().withName(STREAM_NAME_DIMENSION).withValue(streamName)));
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-io-kinesis
public Record convertToRecord() {
return new Record()
.withApproximateArrivalTimestamp(arrivalTimestamp.toDate())
.withData(ByteBuffer.wrap(data.getBytes(StandardCharsets.UTF_8)))
.withSequenceNumber(sequenceNumber)
.withPartitionKey("");
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-io-kinesis
@Test
public void shouldReturnIteratorStartingWithTimestamp() throws Exception {
Instant timestamp = Instant.now();
given(
kinesis.getShardIterator(
new GetShardIteratorRequest()
.withStreamName(STREAM)
.withShardId(SHARD_1)
.withShardIteratorType(ShardIteratorType.AT_SEQUENCE_NUMBER)
.withTimestamp(timestamp.toDate())))
.willReturn(new GetShardIteratorResult().withShardIterator(SHARD_ITERATOR));
String stream =
underTest.getShardIterator(
STREAM, SHARD_1, ShardIteratorType.AT_SEQUENCE_NUMBER, null, timestamp);
assertThat(stream).isEqualTo(SHARD_ITERATOR);
}
内容来源于网络,如有侵权,请联系作者删除!