Java Code Examples for java.time.Instant.EPOCH

The following are Jave code examples for showing how to use EPOCH of the java.time.Instant class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: xm-commons   File: XmLepResourceService.java   View Source Code Vote up 6 votes
private LepResourceDescriptor getLepResourceDescriptor(LepResourceKey resourceKey,
                                                       Resource scriptResource) {
    // get script modification time
    Instant modificationTime;
    try {
        modificationTime = Instant.ofEpochMilli(scriptResource.lastModified());
    } catch (IOException e) {
        throw new IllegalStateException(
            "Error while getting script resource modification time: "
                + e.getMessage(),
            e);
    }

    // build descriptor
    return new DefaultLepResourceDescriptor(getResourceType(resourceKey), resourceKey,
                                            Instant.EPOCH, modificationTime);
}
 
Example 2
Project: xm-ms-entity   File: XmClasspathLepResourceService.java   View Source Code Vote up 6 votes
private LepResourceDescriptor getLepResourceDescriptor(
    LepResourceKey resourceKey,
    Resource scriptResource) {
    // get script modification time
    Instant modificationTime;
    try {
        modificationTime = Instant.ofEpochMilli(scriptResource.lastModified());
    } catch (IOException e) {
        throw new IllegalStateException(
            "Error while getting script resource modification time: "
                + e.getMessage(),
            e);
    }

    // build descriptor
    return new DefaultLepResourceDescriptor(getResourceType(resourceKey), resourceKey,
                                            Instant.EPOCH, modificationTime);
}
 
Example 3
Project: jdk8u-jdk   File: TCKInstant.java   View Source Code Vote up 6 votes
@DataProvider(name="adjustInto")
Object[][] data_adjustInto() {
    return new Object[][]{
            {Instant.ofEpochSecond(10, 200), Instant.ofEpochSecond(20), Instant.ofEpochSecond(10, 200), null},
            {Instant.ofEpochSecond(10, -200), Instant.now(), Instant.ofEpochSecond(10, -200), null},
            {Instant.ofEpochSecond(-10), Instant.EPOCH, Instant.ofEpochSecond(-10), null},
            {Instant.ofEpochSecond(10), Instant.MIN, Instant.ofEpochSecond(10), null},
            {Instant.ofEpochSecond(10), Instant.MAX, Instant.ofEpochSecond(10), null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20).toInstant(ZoneOffset.UTC), Instant.ofEpochSecond(10, 200), null},
            {Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZoneOffset.UTC), OffsetDateTime.of(1970, 1, 1, 0, 0, 10, 200, ZoneOffset.UTC), null},
            {Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, OFFSET_PTWO), OffsetDateTime.of(1970, 1, 1, 2, 0, 10, 200, OFFSET_PTWO), null},
            {Instant.ofEpochSecond(10, 200), ZonedDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZONE_PARIS), ZonedDateTime.of(1970, 1, 1, 1, 0, 10, 200, ZONE_PARIS), null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20), null, DateTimeException.class},
            {Instant.ofEpochSecond(10, 200), null, null, NullPointerException.class},

    };
}
 
Example 4
Project: jdk8u-jdk   File: TCKInstant.java   View Source Code Vote up 6 votes
@DataProvider(name="with")
Object[][] data_with() {
    return new Object[][]{
            {Instant.ofEpochSecond(10, 200), Instant.ofEpochSecond(20), Instant.ofEpochSecond(20), null},
            {Instant.ofEpochSecond(10), Instant.ofEpochSecond(20, -100), Instant.ofEpochSecond(20, -100), null},
            {Instant.ofEpochSecond(-10), Instant.EPOCH, Instant.ofEpochSecond(0), null},
            {Instant.ofEpochSecond(10), Instant.MIN, Instant.MIN, null},
            {Instant.ofEpochSecond(10), Instant.MAX, Instant.MAX, null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20).toInstant(ZoneOffset.UTC), Instant.ofEpochSecond(20), null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20), null, DateTimeException.class},
            {Instant.ofEpochSecond(10, 200), null, null, NullPointerException.class},

    };
}
 
Example 5
Project: openjdk-jdk10   File: TCKInstant.java   View Source Code Vote up 6 votes
@DataProvider(name="adjustInto")
Object[][] data_adjustInto() {
    return new Object[][]{
            {Instant.ofEpochSecond(10, 200), Instant.ofEpochSecond(20), Instant.ofEpochSecond(10, 200), null},
            {Instant.ofEpochSecond(10, -200), Instant.now(), Instant.ofEpochSecond(10, -200), null},
            {Instant.ofEpochSecond(-10), Instant.EPOCH, Instant.ofEpochSecond(-10), null},
            {Instant.ofEpochSecond(10), Instant.MIN, Instant.ofEpochSecond(10), null},
            {Instant.ofEpochSecond(10), Instant.MAX, Instant.ofEpochSecond(10), null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20).toInstant(ZoneOffset.UTC), Instant.ofEpochSecond(10, 200), null},
            {Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZoneOffset.UTC), OffsetDateTime.of(1970, 1, 1, 0, 0, 10, 200, ZoneOffset.UTC), null},
            {Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, OFFSET_PTWO), OffsetDateTime.of(1970, 1, 1, 2, 0, 10, 200, OFFSET_PTWO), null},
            {Instant.ofEpochSecond(10, 200), ZonedDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZONE_PARIS), ZonedDateTime.of(1970, 1, 1, 1, 0, 10, 200, ZONE_PARIS), null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20), null, DateTimeException.class},
            {Instant.ofEpochSecond(10, 200), null, null, NullPointerException.class},

    };
}
 
Example 6
Project: openjdk-jdk10   File: TCKInstant.java   View Source Code Vote up 6 votes
@DataProvider(name="with")
Object[][] data_with() {
    return new Object[][]{
            {Instant.ofEpochSecond(10, 200), Instant.ofEpochSecond(20), Instant.ofEpochSecond(20), null},
            {Instant.ofEpochSecond(10), Instant.ofEpochSecond(20, -100), Instant.ofEpochSecond(20, -100), null},
            {Instant.ofEpochSecond(-10), Instant.EPOCH, Instant.ofEpochSecond(0), null},
            {Instant.ofEpochSecond(10), Instant.MIN, Instant.MIN, null},
            {Instant.ofEpochSecond(10), Instant.MAX, Instant.MAX, null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20).toInstant(ZoneOffset.UTC), Instant.ofEpochSecond(20), null},

            {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20), null, DateTimeException.class},
            {Instant.ofEpochSecond(10, 200), null, null, NullPointerException.class},

    };
}
 
Example 7
Project: swblocks-decisiontree   File: ResultNodeTest.java   View Source Code Vote up 6 votes
@Test
public void testStringDatedResultNode() {
    final TreeNode treeNode =
            NodeSupplier.createDatedResultTreeNode(createStringDriver("TestInput"),
                    NodeSupplier.ROOT_NODE_LEVEL, getRule()).get();
    final ResultNode resultNode = (ResultNode) treeNode;
    final BaseTreeNode baseTreeNode = (BaseTreeNode) treeNode;

    assertEquals(new UUID(0, 1L), resultNode.getRuleIdentifier());
    assertEquals(14L, resultNode.getWeight());

    assertTrue(resultNode.evaluate("TestInput"));
    assertFalse(resultNode.evaluate("TestInputs"));

    assertTrue(resultNode.getDriverType() == InputValueType.STRING);
    // a result node never equals another
    assertFalse(resultNode.equals(resultNode));

    final InputDriver driverValue = baseTreeNode.getDriver();
    assertTrue(driverValue.getValue().equals("TestInput"));

    final Range<Instant> range = new Range<>(Instant.EPOCH, DecisionTreeRule.MAX);
    assertEquals(range, treeNode.getDateRange());
}
 
Example 8
Project: trading4j   File: DatedCandleStickTest.java   View Source Code Vote up 6 votes
/**
 * A {@link DatedCandleStick} {@link Object#equals(Object)} only other {@link DatedCandleStick} that have the same
 * value.
 * 
 * <p>
 * A {@link DatedCandleStick} can also be equal to instances of sub-class of {@link DatedCandleStick}.
 * </p>
 */
@Test
public void shouldBeEqualToOtherDatedCandleSticksWithSameValue() {
    final Instant someTime = Instant.EPOCH;
    final Instant otherTime = Instant.EPOCH.plus(1, MINUTES);

    assertThat(new DatedCandleStick<>(someTime, 1.0, 2.0, 3.0, 4.0)).isEqualTo(
            new DatedCandleStick<>(someTime, new Price(1.0), new Price(2.0), new Price(3.0), new Price(4.0)));
    assertThat(new DatedCandleStick<>(someTime, 1.0, 2.0, 3.0, 4.0)).isEqualTo(
            new ExemplaryDatedCandleStickSubClass(someTime, 1.0, 2.0, 3.0, 4.0, 42));
    assertThat(new DatedCandleStick<>(someTime, 1.0, 2.592, 1.12345, 5.12345)).isEqualTo(
            new DatedCandleStick<>(someTime, 1.0, 2.592, 1.123449, 5.12345018));

    assertThat(new DatedCandleStick<>(someTime, 1.0, 2.0, 3.0, 4.0)).isNotEqualTo(
            new DatedCandleStick<>(otherTime, 1.0, 2.0, 3.0, 4.0));
    assertThat(new DatedCandleStick<>(someTime, 1.0, 2.592, 1.12345, 5.12345)).isNotEqualTo(
            new DatedCandleStick<>(someTime, 1.0, 2.592, 1.12346, 5.12343));
    assertThat(new DatedCandleStick<>(someTime, 1.0, 2.0, 3.0, 4.0)).isNotEqualTo("not a candle stick");
    assertThat(new DatedCandleStick<>(someTime, 1.0, 2.0, 3.0, 4.02)).isNotEqualTo(null);
}
 
Example 9
Project: trading4j   File: FullMarketDataTest.java   View Source Code Vote up 5 votes
/**
 * A {@link FullMarketData} {@link Object#equals(Object)} only other {@link FullMarketData} that have the same
 * value.
 * 
 * <p>
 * A {@link FullMarketData} can also be equal to instances of sub-class of {@link FullMarketData}.
 * </p>
 */
@Test
public void shouldBeEqualToOtherFatCandleSticksWithSameValue() {
    final Instant someTime = Instant.EPOCH;
    final Instant otherTime = Instant.EPOCH.plus(1, MINUTES);

    assertThat(
            new FullMarketData<>(someTime, new Price(1.0), new Price(2.0), new Price(3.0), new Price(4.0),
                    new Price(5.0), new Volume(5, VolumeUnit.LOT), 50)).isEqualTo(
            new FullMarketData<>(someTime, new Price(1.0), new Price(2.0), new Price(3.0), new Price(4.0),
                    new Price(5.0), new Volume(50, VolumeUnit.MINI_LOT), 50));
    assertThat(
            new FullMarketData<>(someTime, new Price(1.0), new Price(2.0), new Price(3.0), new Price(4.0),
                    new Price(5.0), new Volume(5, VolumeUnit.LOT), 50)).isEqualTo(
            new ExemplaryFatCandleStickSubClass(someTime, new Price(1.0), new Price(2.0), new Price(3.0),
                    new Price(4.0), new Price(5.0), new Volume(5, VolumeUnit.LOT), 50, 42));

    assertThat(
            new FullMarketData<>(someTime, new Price(1.0), new Price(2.0), new Price(3.0), new Price(4.0),
                    new Price(5.0), new Volume(5, VolumeUnit.LOT), 50)).isNotEqualTo(
            new FullMarketData<>(otherTime, new Price(1.0), new Price(2.0), new Price(3.0), new Price(4.0),
                    new Price(5.0), new Volume(5, VolumeUnit.LOT), 32));
    assertThat(
            new FullMarketData<>(someTime, new Price(1.0), new Price(2.0), new Price(3.0), new Price(4.0),
                    new Price(5.0), new Volume(5, VolumeUnit.LOT), 5432)).isNotEqualTo(
            new FullMarketData<>(someTime, new Price(1.0), new Price(2.0), new Price(3.0), new Price(4.0),
                    new Price(5.0), new Volume(5, VolumeUnit.LOT), 50));
    assertThat(
            new FullMarketData<>(someTime, new Price(1.0), new Price(2.0), new Price(3.0), new Price(4.0),
                    new Price(5.0), new Volume(5, VolumeUnit.LOT), 50)).isNotEqualTo("not a candle stick");
    assertThat(
            new FullMarketData<>(someTime, new Price(1.0), new Price(2.0), new Price(3.0), new Price(4.0),
                    new Price(5.0), new Volume(5, VolumeUnit.LOT), 50)).isNotEqualTo(null);
}
 
Example 10
Project: ProjectAres   File: LocalUserDocument.java   View Source Code Vote up 4 votes
@Override
public @Nullable Instant granted_tnt_license_at() {
    return Instant.EPOCH;
}
 
Example 11
Project: tg-eventstore   File: BackdatingEventReader.java   View Source Code Vote up 4 votes
public BackdatingEventReader(EventReader underlying, Instant liveCutoverInclusive) {
    this(underlying, liveCutoverInclusive, Instant.EPOCH);
}
 
Example 12
Project: rskj   File: BridgeSupportTest.java   View Source Code Vote up 4 votes
@Test
public void minimumProcessFundsMigrationValue() throws IOException, BlockStoreException {
    BridgeConstants bridgeConstants = BridgeRegTestConstants.getInstance();
    Federation oldFederation = bridgeConstants.getGenesisFederation();
    Federation newFederation = new Federation(
            Collections.singletonList(new BtcECKey(new SecureRandom())),
            Instant.EPOCH,
            5L,
            bridgeConstants.getBtcParams()
    );

    BridgeStorageProvider provider = mock(BridgeStorageProvider.class);
    when(provider.getFeePerKb())
            .thenReturn(Coin.MILLICOIN);
    when(provider.getReleaseRequestQueue())
            .thenReturn(new ReleaseRequestQueue(Collections.emptyList()));
    when(provider.getReleaseTransactionSet())
            .thenReturn(new ReleaseTransactionSet(Collections.emptySet()));
    when(provider.getOldFederation())
            .thenReturn(oldFederation);
    when(provider.getNewFederation())
            .thenReturn(newFederation);

    BlockGenerator blockGenerator = new BlockGenerator();
    // Old federation will be in migration age at block 35
    org.ethereum.core.Block rskCurrentBlock = blockGenerator.createBlock(35, 1);
    Transaction tx = Transaction.create(ConfigHelper.CONFIG, TO_ADDRESS, DUST_AMOUNT, NONCE, GAS_PRICE, GAS_LIMIT, DATA);

    Repository repository = new RepositoryImpl(ConfigHelper.CONFIG);
    Repository track = repository.startTracking();
    BridgeSupport bridgeSupport = new BridgeSupport(ConfigHelper.CONFIG, track, mock(BridgeEventLogger.class), provider, rskCurrentBlock);

    // One MICROCOIN is less than half the fee per kb, which is the minimum funds to migrate,
    // and so it won't be removed from the old federation UTXOs list for migration.
    List<UTXO> unsufficientUTXOsForMigration1 = new ArrayList<>();
    unsufficientUTXOsForMigration1.add(createUTXO(Coin.MICROCOIN, oldFederation.getAddress()));
    when(provider.getOldFederationBtcUTXOs())
            .thenReturn(unsufficientUTXOsForMigration1);
    bridgeSupport.updateCollections(tx);
    assertThat(unsufficientUTXOsForMigration1.size(), is(1));

    // MILLICOIN is greater than half the fee per kb,
    // and it will be removed from the old federation UTXOs list for migration.
    List<UTXO> sufficientUTXOsForMigration1 = new ArrayList<>();
    sufficientUTXOsForMigration1.add(createUTXO(Coin.MILLICOIN, oldFederation.getAddress()));
    when(provider.getOldFederationBtcUTXOs())
            .thenReturn(sufficientUTXOsForMigration1);

    bridgeSupport.updateCollections(tx);
    assertThat(sufficientUTXOsForMigration1.size(), is(0));

    // 2 smaller coins should work exactly like 1 MILLICOIN
    List<UTXO> sufficientUTXOsForMigration2 = new ArrayList<>();
    sufficientUTXOsForMigration2.add(createUTXO(Coin.MILLICOIN.divide(2), oldFederation.getAddress()));
    sufficientUTXOsForMigration2.add(createUTXO(Coin.MILLICOIN.divide(2), oldFederation.getAddress()));
    when(provider.getOldFederationBtcUTXOs())
            .thenReturn(sufficientUTXOsForMigration2);

    bridgeSupport.updateCollections(tx);
    assertThat(sufficientUTXOsForMigration2.size(), is(0));

    // higher fee per kb prevents funds migration
    List<UTXO> unsufficientUTXOsForMigration2 = new ArrayList<>();
    unsufficientUTXOsForMigration2.add(createUTXO(Coin.MILLICOIN, oldFederation.getAddress()));
    when(provider.getOldFederationBtcUTXOs())
            .thenReturn(unsufficientUTXOsForMigration2);
    when(provider.getFeePerKb())
            .thenReturn(Coin.COIN);

    bridgeSupport.updateCollections(tx);
    assertThat(unsufficientUTXOsForMigration2.size(), is(1));
}
 
Example 13
Project: ge-export   File: Application.java   View Source Code Vote up 4 votes
public static void main(String[] args) throws Exception {
    //ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);

    try {

        String propertiesFile = System.getProperty(GE_EXPORT_DATABASE_PROPERTIES_KEY, "db-info.properties");
        LOGGER.info("Validating connection to the target database from configuration file: {}", propertiesFile);
        Properties dbProps = PropertiesUtils.getPropertiesFromClasspath(propertiesFile);
        try {
            Yank.setupDefaultConnectionPool(dbProps);
            SqlHelper.loadSqlQueries();
        } catch (Throwable t) {
            LOGGER.error("Unable to connect to the target database.  Please validate your configuration settings.");
            throw new RuntimeException("Failed to establish connection to target database.", t);
        }

        LOGGER.info("Validating connection to Gradle Enterprise");
        // This ignores authentication
        performHealthCheck();
        // This does NOT ignore authentication
        performAuthenticationCheck();

        if (System.getProperty("createDb") != null) {
            CreateDB.run();
        }

        String hoursStr = System.getProperty("hours", "24");
        Instant since;
        if (hoursStr.equals("all")) {
            since = Instant.EPOCH;
            LOGGER.info("Calculating for all stored build scans");
        } else {
            since = now().minus(Duration.ofHours(Integer.parseInt(hoursStr)));
        }

        buildIdStream(since)
                .flatMap(buildId -> buildEventStream(buildId)
                                .reduce(new EventProcessor(buildId), EventProcessor::process),
                        NUM_OF_STREAMS
                )
                .toBlocking()
                .subscribe(
                        EventProcessor::persist
                );

        Yank.releaseDefaultConnectionPool();
    } catch (Exception e) {
        LOGGER.error("Export failed ", e);
        System.exit(1);
    }
}
 
Example 14
Project: jdk8u-jdk   File: TCKInstant.java   View Source Code Vote up 4 votes
@Override
protected List<TemporalAccessor> samples() {
    TemporalAccessor[] array = {TEST_12345_123456789, Instant.MIN, Instant.MAX, Instant.EPOCH};
    return Arrays.asList(array);
}
 
Example 15
Project: openjdk-jdk10   File: TCKInstant.java   View Source Code Vote up 4 votes
@Override
protected List<TemporalAccessor> samples() {
    TemporalAccessor[] array = {TEST_12345_123456789, Instant.MIN, Instant.MAX, Instant.EPOCH};
    return Arrays.asList(array);
}
 
Example 16
Project: swblocks-decisiontree   File: ResultNodeTest.java   View Source Code Vote up 4 votes
private DecisionTreeRule getRule() {
    return new DecisionTreeRule(new UUID(0, 1), UUID.randomUUID(),
            getInputDriverArray("*", "CME", "S&P", "US", "*"),
            Collections.emptyMap(), Instant.EPOCH, DecisionTreeRule.MAX);
}