本文整理了Java中org.joda.time.DateTime.plusMillis()
方法的一些代码示例,展示了DateTime.plusMillis()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTime.plusMillis()
方法的具体详情如下:
包路径:org.joda.time.DateTime
类名称:DateTime
方法名:plusMillis
[英]Returns a copy of this datetime plus the specified number of millis.
The calculation will add a duration equivalent to the number of milliseconds.
The following three lines are identical in effect:
DateTime added = dt.plusMillis(6);
DateTime added = dt.plus(Period.millis(6));
DateTime added = dt.withFieldAdded(DurationFieldType.millis(), 6);
This datetime instance is immutable and unaffected by this method call.
[中]返回此日期时间加上指定毫秒数的副本。
计算将添加与毫秒数相等的持续时间。
以下三行实际上是相同的:
DateTime added = dt.plusMillis(6);
DateTime added = dt.plus(Period.millis(6));
DateTime added = dt.withFieldAdded(DurationFieldType.millis(), 6);
此datetime实例是不可变的,不受此方法调用的影响。
代码示例来源:origin: gocd/gocd
public DateTime timeoutTime(long timeoutInMillis) {
return new DateTime().plusMillis((int) timeoutInMillis);
}
}
代码示例来源:origin: apache/incubator-druid
protected void flushAfterDuration(final long truncatedTime, final Sink sink)
{
log.info(
"Abandoning segment %s at %s",
sink.getSegment().getId(),
DateTimes.nowUtc().plusMillis((int) flushDuration.getMillis())
);
ScheduledExecutors.scheduleWithFixedDelay(
flushScheduledExec,
flushDuration,
new Callable<ScheduledExecutors.Signal>()
{
@Override
public ScheduledExecutors.Signal call()
{
log.info("Abandoning segment %s", sink.getSegment().getId());
abandonSegment(truncatedTime, sink);
return ScheduledExecutors.Signal.STOP;
}
}
);
}
代码示例来源:origin: gocd/gocd
@Test
public void shouldGiveTimeoutTime() throws Exception {
DateTime expected = new DateTime().plusMillis((int) Timeout.NINETY_SECONDS.inMillis());
DateTime actual = new SystemTimeClock().timeoutTime(Timeout.NINETY_SECONDS);
assertThat(actual.equals(expected) || actual.isAfter(expected),is(true));
}
}
代码示例来源:origin: apache/incubator-druid
@Test(timeout = 60_000L)
public void testShutdown() throws Exception
{
EasyMock.expect(req.getAttribute(AuthConfig.DRUID_AUTHORIZATION_CHECKED))
.andReturn(null)
.anyTimes();
EasyMock.expect(req.getAttribute(AuthConfig.DRUID_ALLOW_UNSECURED_PATH)).andReturn(null).anyTimes();
EasyMock.expect(req.getAttribute(AuthConfig.DRUID_AUTHENTICATION_RESULT))
.andReturn(AllowAllAuthenticator.ALLOW_ALL_RESULT)
.anyTimes();
req.setAttribute(AuthConfig.DRUID_AUTHORIZATION_CHECKED, true);
EasyMock.expectLastCall().anyTimes();
EasyMock.replay(req);
firehose.shutdown(DateTimes.nowUtc().plusMillis(100).toString(), req);
while (!firehose.isClosed()) {
Thread.sleep(50);
}
}
代码示例来源:origin: killbill/killbill
@Test(groups = "slow")
public void test() throws Exception {
final UUID accountId = new UUID(0L, 1L);
final Account account = Mockito.mock(Account.class);
Mockito.when(account.getId()).thenReturn(accountId);
Mockito.when(accountApi.getImmutableAccountDataByRecordId(Mockito.eq(internalCallContext.getAccountRecordId()), Mockito.<InternalTenantContext>any())).thenReturn(account);
final DateTime now = clock.getUTCNow();
final DateTime readyTime = now.plusMillis(2000);
final OverdueCheckNotificationKey notificationKey = new OverdueCheckNotificationKey(accountId);
checkPoster.insertOverdueNotification(accountId, readyTime, OverdueCheckNotifier.OVERDUE_CHECK_NOTIFIER_QUEUE, notificationKey, internalCallContext);
// Move time in the future after the notification effectiveDate
clock.setDeltaFromReality(3000);
await().atMost(5, SECONDS).until(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return mockDispatcher.getEventCount() == 1;
}
});
Assert.assertEquals(mockDispatcher.getEventCount(), 1);
Assert.assertEquals(mockDispatcher.getLatestAccountId(), accountId);
}
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testUsedOverlapEnd() throws IOException
{
coordinator.announceHistoricalSegments(SEGMENTS);
Assert.assertEquals(
SEGMENTS,
ImmutableSet.copyOf(
coordinator.getUsedSegmentsForInterval(
defaultSegment.getDataSource(),
defaultSegment.getInterval().withEnd(defaultSegment.getInterval().getEnd().plusMillis(1))
)
)
);
}
代码示例来源:origin: prestodb/presto
@Test
public void testAddFieldToTimestamp()
{
assertFunction("date_add('millisecond', 3, " + TIMESTAMP_LITERAL + ")", TimestampType.TIMESTAMP, sqlTimestampOf(TIMESTAMP.plusMillis(3), session));
assertFunction("date_add('second', 3, " + TIMESTAMP_LITERAL + ")", TimestampType.TIMESTAMP, sqlTimestampOf(TIMESTAMP.plusSeconds(3), session));
assertFunction("date_add('minute', 3, " + TIMESTAMP_LITERAL + ")", TimestampType.TIMESTAMP, sqlTimestampOf(TIMESTAMP.plusMinutes(3), session));
assertFunction("date_add('hour', 3, " + TIMESTAMP_LITERAL + ")", TimestampType.TIMESTAMP, sqlTimestampOf(TIMESTAMP.plusHours(3), session));
assertFunction("date_add('hour', 23, " + TIMESTAMP_LITERAL + ")", TimestampType.TIMESTAMP, sqlTimestampOf(TIMESTAMP.plusHours(23), session));
assertFunction("date_add('hour', -4, " + TIMESTAMP_LITERAL + ")", TimestampType.TIMESTAMP, sqlTimestampOf(TIMESTAMP.minusHours(4), session));
assertFunction("date_add('hour', -23, " + TIMESTAMP_LITERAL + ")", TimestampType.TIMESTAMP, sqlTimestampOf(TIMESTAMP.minusHours(23), session));
assertFunction("date_add('day', 3, " + TIMESTAMP_LITERAL + ")", TimestampType.TIMESTAMP, sqlTimestampOf(TIMESTAMP.plusDays(3), session));
assertFunction("date_add('week', 3, " + TIMESTAMP_LITERAL + ")", TimestampType.TIMESTAMP, sqlTimestampOf(TIMESTAMP.plusWeeks(3), session));
assertFunction("date_add('month', 3, " + TIMESTAMP_LITERAL + ")", TimestampType.TIMESTAMP, sqlTimestampOf(TIMESTAMP.plusMonths(3), session));
assertFunction("date_add('quarter', 3, " + TIMESTAMP_LITERAL + ")", TimestampType.TIMESTAMP, sqlTimestampOf(TIMESTAMP.plusMonths(3 * 3), session));
assertFunction("date_add('year', 3, " + TIMESTAMP_LITERAL + ")", TimestampType.TIMESTAMP, sqlTimestampOf(TIMESTAMP.plusYears(3), session));
assertFunction("date_add('millisecond', 3, " + WEIRD_TIMESTAMP_LITERAL + ")", TIMESTAMP_WITH_TIME_ZONE, toTimestampWithTimeZone(WEIRD_TIMESTAMP.plusMillis(3)));
assertFunction("date_add('second', 3, " + WEIRD_TIMESTAMP_LITERAL + ")", TIMESTAMP_WITH_TIME_ZONE, toTimestampWithTimeZone(WEIRD_TIMESTAMP.plusSeconds(3)));
assertFunction("date_add('minute', 3, " + WEIRD_TIMESTAMP_LITERAL + ")", TIMESTAMP_WITH_TIME_ZONE, toTimestampWithTimeZone(WEIRD_TIMESTAMP.plusMinutes(3)));
assertFunction("date_add('hour', 3, " + WEIRD_TIMESTAMP_LITERAL + ")", TIMESTAMP_WITH_TIME_ZONE, toTimestampWithTimeZone(WEIRD_TIMESTAMP.plusHours(3)));
assertFunction("date_add('day', 3, " + WEIRD_TIMESTAMP_LITERAL + ")", TIMESTAMP_WITH_TIME_ZONE, toTimestampWithTimeZone(WEIRD_TIMESTAMP.plusDays(3)));
assertFunction("date_add('week', 3, " + WEIRD_TIMESTAMP_LITERAL + ")", TIMESTAMP_WITH_TIME_ZONE, toTimestampWithTimeZone(WEIRD_TIMESTAMP.plusWeeks(3)));
assertFunction("date_add('month', 3, " + WEIRD_TIMESTAMP_LITERAL + ")", TIMESTAMP_WITH_TIME_ZONE, toTimestampWithTimeZone(WEIRD_TIMESTAMP.plusMonths(3)));
assertFunction("date_add('quarter', 3, " + WEIRD_TIMESTAMP_LITERAL + ")", TIMESTAMP_WITH_TIME_ZONE, toTimestampWithTimeZone(WEIRD_TIMESTAMP.plusMonths(3 * 3)));
assertFunction("date_add('year', 3, " + WEIRD_TIMESTAMP_LITERAL + ")", TIMESTAMP_WITH_TIME_ZONE, toTimestampWithTimeZone(WEIRD_TIMESTAMP.plusYears(3)));
}
代码示例来源:origin: facebook/jcommon
private EventCounterIf<EventCounter> nextCurrentCounter(ReadableDateTime now) {
EventCounter eventCounter =
new EventCounterImpl(now, now.toDateTime().plusMillis(timeBucketSizeMillis));
allTimeCounter.addEventCounter(eventCounter);
hourCounter.addEventCounter(eventCounter);
tenMinuteCounter.addEventCounter(eventCounter);
minuteCounter.addEventCounter(eventCounter);
return eventCounter;
}
代码示例来源:origin: io.nflow/nflow-engine
/**
* Return the delay before next activation after detecting a busy loop.
*
* @return The delay in milliseconds.
*/
public DateTime getShortTransitionActivation() {
return now().plusMillis(shortTransitionDelay);
}
代码示例来源:origin: com.ning.billing/killbill-meter
public TimelineSourceEventAccumulator(final TimelineDao dao, final TimelineCoder timelineCoder, final SampleCoder sampleCoder,
final BackgroundDBChunkWriter backgroundWriter, final int sourceId, final int eventCategoryId,
final DateTime firstSampleTime, final Integer timelineLengthMillis) {
this.timelineLengthMillis = timelineLengthMillis;
this.backgroundWriter = backgroundWriter;
this.timelineCoder = timelineCoder;
this.sampleCoder = sampleCoder;
this.sourceId = sourceId;
this.eventCategoryId = eventCategoryId;
// Set the end-of-chunk time by tossing a random number, to evenly distribute the db writeback load.
this.chunkEndTime = timelineLengthMillis != null ? firstSampleTime.plusMillis(rand.nextInt(timelineLengthMillis)) : null;
}
代码示例来源:origin: qcadoo/mes
private Date calculateOrderStartDate(Date finishDate, Integer changeoverDurationInMillis) {
DateTime finishDateTime = new DateTime(finishDate);
finishDateTime = finishDateTime.plusMillis(changeoverDurationInMillis);
return finishDateTime.toDate();
}
代码示例来源:origin: stackoverflow.com
DateTime dt = new DateTime("2014-09-15T21:20:14", DateTimeZone.UTC);
System.out.println(dt);
DateTime other = dt.plusMillis(581042272);
System.out.println(other);
代码示例来源:origin: stackoverflow.com
DateTime udate = new DateTime("2016-05-01T20:10:04", DateTimeZone.UTC);
System.out.println(udate);
DateTime zone = udate.plusMillis(10000)
.withZone(DateTimeZone.forID("Asia/Kolkata"));
System.out.println(zone);
代码示例来源:origin: org.modeshape/modeshape-graph
/**
* {@inheritDoc}
*
* @see org.modeshape.graph.property.DateTime#plusMillis(int)
*/
public org.modeshape.graph.property.DateTime plusMillis( int milliseconds ) {
return new JodaDateTime(this.instance.plusMillis(milliseconds));
}
代码示例来源:origin: metatron-app/metatron-discovery
private List<DateTime> getMillisLabels(DateTime min, DateTime max, int unitSize) {
List<DateTime> labels = new ArrayList<>();
DateTime dt = new DateTime(min.getYear(), min.getMonthOfYear(), min.getDayOfMonth(),
min.getHourOfDay(), min.getMinuteOfHour(), min.getSecondOfMinute(), min.getMillisOfSecond() / unitSize * unitSize);
while (dt.isBefore(max) || dt.isEqual(max)) {
labels.add(dt);
dt = dt.plusMillis(unitSize);
}
labels.add(dt);
return labels;
}
代码示例来源:origin: spring-projects/spring-security-saml
protected boolean isDateTimeSkewValid(int skewMillis, int forwardMillis, DateTime time) {
if (time == null) {
return false;
}
final DateTime reference = new DateTime();
final Interval validTimeInterval = new Interval(
reference.minusMillis(skewMillis + forwardMillis),
reference.plusMillis(skewMillis)
);
return validTimeInterval.contains(time);
}
代码示例来源:origin: io.airlift.discovery/discovery-server
@Override
public synchronized void put(Id<Node> nodeId, DynamicAnnouncement announcement)
{
Preconditions.checkNotNull(nodeId, "nodeId is null");
Preconditions.checkNotNull(announcement, "announcement is null");
Set<Service> services = ImmutableSet.copyOf(transform(announcement.getServiceAnnouncements(), toServiceWith(nodeId, announcement.getLocation(), announcement.getPool())));
DateTime expiration = currentTime.get().plusMillis((int) maxAge.toMillis());
descriptors.put(nodeId, new Entry(expiration, services));
}
代码示例来源:origin: bingoohuang/quartz-glass
@Override
public void jobEnds(JobExecution execution, JobExecutionContext context) {
String sql = "update " + getTableName() + " set endDate = :endDate, ended = :ended, result = :result where id = :id";
SqlParameterSource params = new MapSqlParameterSource()
.addValue("endDate", new DateTime(context.getFireTime()).plusMillis((int) context.getJobRunTime()).toDate())
.addValue("ended", true)
.addValue("result", execution.getResult().name())
.addValue("id", execution.getId());
jdbcTemplate.update(sql, params);
}
代码示例来源:origin: metamx/java-util
public TestInterval(int years, int months, int days, int hours, int minutes, int seconds, int millis)
{
end = start.plusYears(years)
.plusMonths(months)
.plusDays(days)
.plusHours(hours)
.plusMinutes(minutes)
.plusSeconds(seconds)
.plusMillis(millis);
interval = new Interval(start, end);
}
代码示例来源:origin: uk.co.nichesolutions.presto/presto-main
@Test
public void testAddFieldToTime()
{
assertFunction("date_add('millisecond', 3, " + TIME_LITERAL + ")", TimeType.TIME, toTime(TIME.plusMillis(3)));
assertFunction("date_add('second', 3, " + TIME_LITERAL + ")", TimeType.TIME, toTime(TIME.plusSeconds(3)));
assertFunction("date_add('minute', 3, " + TIME_LITERAL + ")", TimeType.TIME, toTime(TIME.plusMinutes(3)));
assertFunction("date_add('hour', 3, " + TIME_LITERAL + ")", TimeType.TIME, toTime(TIME.plusHours(3)));
assertFunction("date_add('millisecond', 3, " + WEIRD_TIME_LITERAL + ")", TIME_WITH_TIME_ZONE, toTimeWithTimeZone(WEIRD_TIME.plusMillis(3)));
assertFunction("date_add('second', 3, " + WEIRD_TIME_LITERAL + ")", TIME_WITH_TIME_ZONE, toTimeWithTimeZone(WEIRD_TIME.plusSeconds(3)));
assertFunction("date_add('minute', 3, " + WEIRD_TIME_LITERAL + ")", TIME_WITH_TIME_ZONE, toTimeWithTimeZone(WEIRD_TIME.plusMinutes(3)));
assertFunction("date_add('hour', 3, " + WEIRD_TIME_LITERAL + ")", TIME_WITH_TIME_ZONE, toTimeWithTimeZone(WEIRD_TIME.plusHours(3)));
}
内容来源于网络,如有侵权,请联系作者删除!