org.joda.time.DateTime.plus()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(263)

本文整理了Java中org.joda.time.DateTime.plus()方法的一些代码示例,展示了DateTime.plus()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTime.plus()方法的具体详情如下:
包路径:org.joda.time.DateTime
类名称:DateTime
方法名:plus

DateTime.plus介绍

[英]Returns a copy of this datetime with the specified duration added.

If the amount is zero or null, then this is returned. This datetime instance is immutable and unaffected by this method call.
[中]返回添加了指定持续时间的此datetime的副本。
如果金额为零或空,则返回this。此datetime实例是不可变的,不受此方法调用的影响。

代码示例

代码示例来源:origin: apache/incubator-druid

@Override
public DateTime increment(DateTime time)
{
 return time.plus(1);
}

代码示例来源:origin: apache/incubator-druid

@Override
public DateTime increment(DateTime time)
{
 return time.plus(getDuration());
}

代码示例来源:origin: apache/incubator-druid

private void resetNextCheckpointTime()
{
 nextCheckpointTime = DateTimes.nowUtc().plus(tuningConfig.getIntermediateHandoffPeriod()).getMillis();
}

代码示例来源:origin: apache/incubator-druid

private void resetNextFlush()
{
 nextFlush = DateTimes.nowUtc().plus(config.getIntermediatePersistPeriod()).getMillis();
}

代码示例来源:origin: apache/incubator-druid

private void resetNextFlush()
{
 nextFlush = DateTimes.nowUtc().plus(tuningConfig.getIntermediatePersistPeriod()).getMillis();
}

代码示例来源:origin: apache/incubator-druid

Bucket(Interval interval, ArrayList<DataSegment> sortedSegments, double[] leftSum, double[] rightSum)
{
 this.interval = Preconditions.checkNotNull(interval, "interval");
 this.sortedSegments = Preconditions.checkNotNull(sortedSegments, "sortedSegments");
 this.leftSum = Preconditions.checkNotNull(leftSum, "leftSum");
 this.rightSum = Preconditions.checkNotNull(rightSum, "rightSum");
 Preconditions.checkArgument(sortedSegments.size() == leftSum.length && sortedSegments.size() == rightSum.length);
 Preconditions.checkArgument(SEGMENT_ORDERING.isOrdered(sortedSegments));
 this.calculationInterval = new Interval(
   interval.getStart().minus(LIFE_THRESHOLD),
   interval.getEnd().plus(LIFE_THRESHOLD)
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
 public void testAccept()
 {
  Period period = new Period("PT10M");

  RejectionPolicy rejectionPolicy = new ServerTimeRejectionPolicyFactory().create(period);

  DateTime now = DateTimes.nowUtc();
  DateTime past = now.minus(period).minus(100);
  DateTime future = now.plus(period).plus(100);

  Assert.assertTrue(rejectionPolicy.accept(now.getMillis()));
  Assert.assertFalse(rejectionPolicy.accept(past.getMillis()));
  Assert.assertFalse(rejectionPolicy.accept(future.getMillis()));
 }
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testIterableAllSimple()
{
 final DateTime baseTime = DateTimes.of("2011-01-01T00:00:00.000Z");
 assertSameInterval(
   Collections.singletonList(baseTime),
   Granularities.ALL.getIterable(new Interval(baseTime, baseTime.plus(Days.days(3))))
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testIterableAllComplex()
{
 final DateTime baseTime = DateTimes.of("2011-01-01T09:38:02.992Z");
 assertSameInterval(
   Collections.singletonList(baseTime),
   Granularities.ALL.getIterable(new Interval(baseTime, baseTime.plus(Days.days(3))))
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testIterableMonthSimple()
{
 final DateTime baseTime = DateTimes.of("2011-01-01T00:00:00.000Z");
 assertSameInterval(
   Lists.newArrayList(
     DateTimes.of("2011-01-01T00:00:00.000Z"),
     DateTimes.of("2011-02-01T00:00:00.000Z"),
     DateTimes.of("2011-03-01T00:00:00.000Z")
   ),
   Granularities.MONTH.getIterable(new Interval(baseTime, baseTime.plus(Months.THREE)))
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testIterableQuarterSimple()
{
 final DateTime baseTime = DateTimes.of("2011-01-01T00:00:00.000Z");
 assertSameInterval(
   Lists.newArrayList(
     DateTimes.of("2011-01-01T00:00:00.000Z"),
     DateTimes.of("2011-04-01T00:00:00.000Z"),
     DateTimes.of("2011-07-01T00:00:00.000Z")
   ),
   Granularities.QUARTER.getIterable(new Interval(baseTime, baseTime.plus(Months.NINE)))
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testIterableYearSimple()
{
 final DateTime baseTime = DateTimes.of("2011-01-01T00:00:00.000Z");
 assertSameInterval(
   Lists.newArrayList(
     DateTimes.of("2011-01-01T00:00:00.000Z"),
     DateTimes.of("2012-01-01T00:00:00.000Z"),
     DateTimes.of("2013-01-01T00:00:00.000Z")
   ),
   Granularities.YEAR.getIterable(new Interval(baseTime, baseTime.plus(Years.THREE)))
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testIterableMinuteSimple()
{
 final DateTime baseTime = DateTimes.of("2011-01-01T09:38:00.000Z");
 assertSameInterval(
   Lists.newArrayList(
     DateTimes.of("2011-01-01T09:38:00.000Z"),
     DateTimes.of("2011-01-01T09:39:00.000Z"),
     DateTimes.of("2011-01-01T09:40:00.000Z")
   ),
   Granularities.MINUTE.getIterable(new Interval(baseTime, baseTime.plus(Minutes.THREE)))
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testIterableWeekSimple()
{
 final DateTime baseTime = DateTimes.of("2011-01-03T00:00:00.000Z");
 assertSameInterval(
   Lists.newArrayList(
     DateTimes.of("2011-01-03T00:00:00.000Z"),
     DateTimes.of("2011-01-10T00:00:00.000Z"),
     DateTimes.of("2011-01-17T00:00:00.000Z")
   ),
   Granularities.WEEK.getIterable(new Interval(baseTime, baseTime.plus(Weeks.THREE)))
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testIterableHourSimple()
{
 final DateTime baseTime = DateTimes.of("2011-01-01T09:00:00.000Z");
 assertSameInterval(
   Lists.newArrayList(
     DateTimes.of("2011-01-01T09:00:00.000Z"),
     DateTimes.of("2011-01-01T10:00:00.000Z"),
     DateTimes.of("2011-01-01T11:00:00.000Z")
   ), Granularities.HOUR.getIterable(new Interval(baseTime, baseTime.plus(Hours.hours(3))))
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testIterableDaySimple()
{
 final DateTime baseTime = DateTimes.of("2011-01-01T00:00:00.000Z");
 assertSameInterval(
   Lists.newArrayList(
     DateTimes.of("2011-01-01T00:00:00.000Z"),
     DateTimes.of("2011-01-02T00:00:00.000Z"),
     DateTimes.of("2011-01-03T00:00:00.000Z")
   ),
   Granularities.DAY.getIterable(new Interval(baseTime, baseTime.plus(Days.days(3))))
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testIterable15MinuteSimple()
{
 final DateTime baseTime = DateTimes.of("2011-01-01T09:30:00.000Z");
 assertSameInterval(
   Lists.newArrayList(
     DateTimes.of("2011-01-01T09:30:00.000Z"),
     DateTimes.of("2011-01-01T09:45:00.000Z"),
     DateTimes.of("2011-01-01T10:00:00.000Z")
   ),
   Granularities.FIFTEEN_MINUTE.getIterable(new Interval(baseTime, baseTime.plus(Minutes.minutes(45))))
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testIterableHourComplex()
{
 final DateTime baseTime = DateTimes.of("2011-01-01T09:38:02.992Z");
 assertSameInterval(
   Lists.newArrayList(
     DateTimes.of("2011-01-01T09:00:00.000Z"),
     DateTimes.of("2011-01-01T10:00:00.000Z"),
     DateTimes.of("2011-01-01T11:00:00.000Z"),
     DateTimes.of("2011-01-01T12:00:00.000Z")
   ), Granularities.HOUR.getIterable(new Interval(baseTime, baseTime.plus(Hours.hours(3))))
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testIterableDayComplex()
{
 final DateTime baseTime = DateTimes.of("2011-01-01T09:38:02.992Z");
 assertSameInterval(
   Lists.newArrayList(
     DateTimes.of("2011-01-01T00:00:00.000Z"),
     DateTimes.of("2011-01-02T00:00:00.000Z"),
     DateTimes.of("2011-01-03T00:00:00.000Z"),
     DateTimes.of("2011-01-04T00:00:00.000Z")
   ),
   Granularities.DAY.getIterable(new Interval(baseTime, baseTime.plus(Days.days(3))))
 );
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testUnUsedUnderlapLow() throws IOException
{
 coordinator.announceHistoricalSegments(SEGMENTS);
 unUseSegment();
 Assert.assertTrue(
   coordinator.getUnusedSegmentsForInterval(
     defaultSegment.getDataSource(),
     new Interval(defaultSegment.getInterval().getStart().plus(1), defaultSegment.getInterval().getEnd())
   ).isEmpty()
 );
}

相关文章

DateTime类方法