本文整理了Java中org.joda.time.Instant.<init>()
方法的一些代码示例,展示了Instant.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instant.<init>()
方法的具体详情如下:
包路径:org.joda.time.Instant
类名称:Instant
方法名:<init>
[英]Constructs an instance set to the current system millisecond time.
[中]将实例集构造为当前系统毫秒时间。
代码示例来源:origin: dlew/joda-time-android
@Test
public void testGetOffsetFixed_RI() {
DateTimeZone zone = DateTimeZone.forID("+01:00");
assertEquals(1L * DateTimeConstants.MILLIS_PER_HOUR, zone.getOffset(new Instant(TEST_TIME_SUMMER)));
assertEquals(1L * DateTimeConstants.MILLIS_PER_HOUR, zone.getOffset(new Instant(TEST_TIME_WINTER)));
assertEquals(zone.getOffset(DateTimeUtils.currentTimeMillis()), zone.getOffset(null));
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
@Test
public void testSimpleFixedWindow() throws Exception {
Map<IntervalWindow, Set<String>> expected = new HashMap<>();
expected.put(new IntervalWindow(new Instant(0), new Instant(10)), set(1, 2, 5, 9));
expected.put(new IntervalWindow(new Instant(10), new Instant(20)), set(10, 11));
expected.put(new IntervalWindow(new Instant(100), new Instant(110)), set(100));
assertEquals(
expected,
runWindowFn(
FixedWindows.of(new Duration(10)), Arrays.asList(1L, 2L, 5L, 9L, 10L, 11L, 100L)));
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
@Test
public void testTimeUnit() throws Exception {
Map<IntervalWindow, Set<String>> expected = new HashMap<>();
expected.put(new IntervalWindow(new Instant(1), new Instant(2000)), set(1, 2, 1000));
expected.put(new IntervalWindow(new Instant(5000), new Instant(6001)), set(5000, 5001));
expected.put(new IntervalWindow(new Instant(10000), new Instant(11000)), set(10000));
assertEquals(
expected,
runWindowFn(
Sessions.withGapDuration(Duration.standardSeconds(1)),
Arrays.asList(1L, 2L, 1000L, 5000L, 5001L, 10000L)));
}
代码示例来源:origin: org.apache.beam/beam-runners-direct-java
@Test
public void getSynchronizedProcessingTimeIsWatermarkSynchronizedInputTime() {
when(watermarks.getSynchronizedProcessingInputTime()).thenReturn(new Instant(12345L));
assertThat(internals.currentSynchronizedProcessingTime(), equalTo(new Instant(12345L)));
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
@Test
@Category(NeedsRunner.class)
public void testCreateParameterizedType() throws Exception {
PCollection<TimestampedValue<String>> output =
p.apply(
Create.of(
TimestampedValue.of("a", new Instant(0)),
TimestampedValue.of("b", new Instant(0))));
PAssert.that(output)
.containsInAnyOrder(
TimestampedValue.of("a", new Instant(0)), TimestampedValue.of("b", new Instant(0)));
p.run();
}
/** An unserializable class to demonstrate encoding of elements. */
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
@Test
@Category(NeedsRunner.class)
public void withTimestampsBackwardsInTimeShouldThrow() {
SerializableFunction<String, Instant> timestampFn = input -> new Instant(Long.valueOf(input));
SerializableFunction<String, Instant> backInTimeFn =
input -> new Instant(Long.valueOf(input)).minus(Duration.millis(1000L));
String yearTwoThousand = "946684800000";
p.apply(Create.of("1234", "0", Integer.toString(Integer.MAX_VALUE), yearTwoThousand))
.apply("WithTimestamps", WithTimestamps.of(timestampFn))
.apply("AddSkew", WithTimestamps.of(backInTimeFn));
thrown.expect(PipelineExecutionException.class);
thrown.expectCause(isA(IllegalArgumentException.class));
thrown.expectMessage("no earlier than the timestamp of the current input");
p.run();
}
代码示例来源:origin: org.apache.beam/beam-runners-core-construction-java
@Parameters(name = "{index}: {0}")
public static Iterable<TestStream<?>> data() {
return ImmutableList.of(
TestStream.create(VarIntCoder.of()).advanceWatermarkToInfinity(),
TestStream.create(VarIntCoder.of())
.advanceWatermarkTo(new Instant(42))
.advanceWatermarkToInfinity(),
TestStream.create(VarIntCoder.of())
.addElements(TimestampedValue.of(3, new Instant(17)))
.advanceWatermarkToInfinity(),
TestStream.create(StringUtf8Coder.of())
.advanceProcessingTime(Duration.millis(82))
.advanceWatermarkToInfinity());
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
@Override
public void populateDisplayData(Builder builder) {
builder
.add(DisplayData.item("string", stringValue))
.add(DisplayData.item("long", intValue))
.add(DisplayData.item("double", floatValue))
.add(DisplayData.item("boolean", boolValue))
.add(DisplayData.item("instant", new Instant(0)))
.add(DisplayData.item("duration", Duration.millis(durationMillis)))
.add(
DisplayData.item("class", DisplayDataTest.class)
.withLinkUrl("http://abc")
.withLabel("baz"));
}
};
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
@Test
public void testSlightlyOverlapping() throws Exception {
Map<IntervalWindow, Set<String>> expected = new HashMap<>();
expected.put(new IntervalWindow(new Instant(-5), new Instant(2)), set(1));
expected.put(new IntervalWindow(new Instant(0), new Instant(7)), set(1, 2, 5));
expected.put(new IntervalWindow(new Instant(5), new Instant(12)), set(5, 9, 10, 11));
expected.put(new IntervalWindow(new Instant(10), new Instant(17)), set(10, 11));
SlidingWindows windowFn = SlidingWindows.of(new Duration(7)).every(new Duration(5));
assertEquals(expected, runWindowFn(windowFn, Arrays.asList(1L, 2L, 5L, 9L, 10L, 11L)));
assertThat(windowFn.assignsToOneWindow(), is(false));
}
代码示例来源:origin: org.apache.beam/beam-runners-direct-java
@Test
public void getOutputWatermarkTimeUsesWatermarkTime() {
when(watermarks.getOutputWatermark()).thenReturn(new Instant(25525L));
assertThat(internals.currentOutputWatermarkTime(), equalTo(new Instant(25525L)));
}
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
@Test
public void testEquality() {
new EqualsTester()
.addEqualityGroup(
TimestampedValue.of("foo", new Instant(1000)),
TimestampedValue.of("foo", new Instant(1000)))
.addEqualityGroup(TimestampedValue.of("foo", new Instant(2000)))
.addEqualityGroup(TimestampedValue.of("bar", new Instant(1000)))
.addEqualityGroup(
TimestampedValue.of("foo", BoundedWindow.TIMESTAMP_MIN_VALUE),
TimestampedValue.atMinimumTimestamp("foo"))
.testEquals();
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
@Test
public void testConsecutive() throws Exception {
Map<IntervalWindow, Set<String>> expected = new HashMap<>();
expected.put(new IntervalWindow(new Instant(1), new Instant(19)), set(1, 2, 5, 9));
expected.put(new IntervalWindow(new Instant(100), new Instant(111)), set(100, 101));
assertEquals(
expected,
runWindowFn(
Sessions.withGapDuration(new Duration(10)), Arrays.asList(1L, 2L, 5L, 9L, 100L, 101L)));
}
代码示例来源:origin: dlew/joda-time-android
@Test
public void testGetOffset_RI() {
DateTimeZone zone = DateTimeZone.forID("Europe/Paris");
assertEquals(2L * DateTimeConstants.MILLIS_PER_HOUR, zone.getOffset(new Instant(TEST_TIME_SUMMER)));
assertEquals(1L * DateTimeConstants.MILLIS_PER_HOUR, zone.getOffset(new Instant(TEST_TIME_WINTER)));
assertEquals(zone.getOffset(DateTimeUtils.currentTimeMillis()), zone.getOffset(null));
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
@Test
public void testFixedOffsetWindow() throws Exception {
Map<IntervalWindow, Set<String>> expected = new HashMap<>();
expected.put(new IntervalWindow(new Instant(-5), new Instant(5)), set(1, 2));
expected.put(new IntervalWindow(new Instant(5), new Instant(15)), set(5, 9, 10, 11));
expected.put(new IntervalWindow(new Instant(95), new Instant(105)), set(100));
assertEquals(
expected,
runWindowFn(
FixedWindows.of(new Duration(10)).withOffset(new Duration(5)),
Arrays.asList(1L, 2L, 5L, 9L, 10L, 11L, 100L)));
}
代码示例来源:origin: org.apache.beam/beam-runners-direct-java
@Test
public void getSynchronizedProcessingTimeIsWatermarkSynchronizedInputTime() {
when(watermarks.getSynchronizedProcessingInputTime()).thenReturn(new Instant(12345L));
assertThat(internals.currentSynchronizedProcessingTime(), equalTo(new Instant(12345L)));
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
@Test
@Category(NeedsRunner.class)
public void timestampsSucceeds() {
PCollection<String> timestamped =
pipeline.apply(
Create.timestamped(
TimestampedValue.of("foo", new Instant(0L)),
TimestampedValue.of("bar", new Instant(1L))));
PCollection<TimestampedValue<String>> reified = timestamped.apply(Reify.timestamps());
PAssert.that(reified)
.containsInAnyOrder(
TimestampedValue.of("foo", new Instant(0)), TimestampedValue.of("bar", new Instant(1)));
pipeline.run();
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
@Test
public void testFireDeadline() throws Exception {
assertEquals(
BoundedWindow.TIMESTAMP_MAX_VALUE,
Never.ever()
.getWatermarkThatGuaranteesFiring(new IntervalWindow(new Instant(0), new Instant(10))));
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
/** Tests that the watermark that guarantees firing is that of the subtrigger. */
@Test
public void testFireDeadline() throws Exception {
setUp(FixedWindows.of(Duration.millis(10)));
IntervalWindow window = new IntervalWindow(new Instant(0), new Instant(10));
Instant arbitraryInstant = new Instant(34957849);
when(mockTrigger.getWatermarkThatGuaranteesFiring(Mockito.<IntervalWindow>any()))
.thenReturn(arbitraryInstant);
assertThat(
Repeatedly.forever(mockTrigger).getWatermarkThatGuaranteesFiring(window),
equalTo(arbitraryInstant));
}
代码示例来源:origin: org.apache.beam/beam-runners-direct-java
@Test
public void getInputWatermarkTimeUsesWatermarkTime() {
when(watermarks.getInputWatermark()).thenReturn(new Instant(8765L));
assertThat(internals.currentInputWatermarkTime(), equalTo(new Instant(8765L)));
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
@Test
@Category(NeedsRunner.class)
public void testGloballyEventTimestamp() {
PCollection<String> output =
p.apply(
Create.timestamped(
TimestampedValue.of("foo", new Instant(100)),
TimestampedValue.of("bar", new Instant(300)),
TimestampedValue.of("baz", new Instant(200))))
.apply(Latest.globally());
PAssert.that(output).containsInAnyOrder("bar");
p.run();
}
内容来源于网络,如有侵权,请联系作者删除!