本文整理汇总了Java中org.threeten.bp.Instant.ofEpochMilli方法的典型用法代码示例。如果您正苦于以下问题:Java Instant.ofEpochMilli方法的具体用法?Java Instant.ofEpochMilli怎么用?Java Instant.ofEpochMilli使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.threeten.bp.Instant
的用法示例。
在下文中一共展示了Instant.ofEpochMilli方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_get_ExternalIdBundle_VersionCorrection
import org.threeten.bp.Instant; //导入方法依赖的package包/类
public void test_get_ExternalIdBundle_VersionCorrection() {
final SecuritySource underlying = Mockito.mock(SecuritySource.class);
final Instant t1 = Instant.ofEpochMilli(1L);
final Instant t2 = Instant.ofEpochMilli(2L);
final Instant t3 = Instant.ofEpochMilli(3L);
final Instant t4 = Instant.ofEpochMilli(4L);
final SecuritySource test = new VersionLockedSecuritySource(underlying, VersionCorrection.of(t1, t2));
Collection<Security> result = Collections.singleton(Mockito.mock(Security.class));
Mockito.when(underlying.get(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.of(t1, t2))).thenReturn(result);
assertSame(test.get(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.LATEST), result);
assertSame(test.get(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.ofVersionAsOf(t1)), result);
assertSame(test.get(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.ofCorrectedTo(t2)), result);
result = Collections.singleton(Mockito.mock(Security.class));
Mockito.when(underlying.get(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.of(t3, t2))).thenReturn(result);
assertSame(test.get(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.ofVersionAsOf(t3)), result);
result = Collections.singleton(Mockito.mock(Security.class));
Mockito.when(underlying.get(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.of(t1, t3))).thenReturn(result);
assertSame(test.get(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.ofCorrectedTo(t3)), result);
result = Collections.singleton(Mockito.mock(Security.class));
Mockito.when(underlying.get(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.of(t3, t4))).thenReturn(result);
assertSame(test.get(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.of(t3, t4)), result);
}
示例2: load
import org.threeten.bp.Instant; //导入方法依赖的package包/类
/**
* Loads the function cache from disk (if available).
*
* @param annotationClass the annotation class, not null
* @return the cache object, not null
*/
public static AnnotationCache load(Class<? extends Annotation> annotationClass) {
ArgumentChecker.notNull(annotationClass, "annotation class");
final String path = System.getProperty(CACHE_PATH_PROPERTY);
if (path == null) {
s_logger.warn("No cache path set in system property {}", CACHE_PATH_PROPERTY);
return new AnnotationCache(Instant.EPOCH, annotationClass);
}
final File cacheFile = new File(new File(path), getCacheFileName(annotationClass));
try {
final BufferedReader br = new BufferedReader(new FileReader(cacheFile));
String str = br.readLine();
final AnnotationCache cache = new AnnotationCache(Instant.ofEpochMilli(Long.parseLong(str.trim())), annotationClass);
while ((str = br.readLine()) != null) {
str = str.trim();
if (str.length() > 0) {
cache.add(str);
}
}
br.close();
return cache;
} catch (Throwable t) {
s_logger.warn("Couldn't read cache file", t);
return new AnnotationCache(Instant.EPOCH, annotationClass);
}
}
示例3: test_getSingle_ExternalIdBundle_VersionCorrection
import org.threeten.bp.Instant; //导入方法依赖的package包/类
public void test_getSingle_ExternalIdBundle_VersionCorrection() {
final SecuritySource underlying = Mockito.mock(SecuritySource.class);
final Instant t1 = Instant.ofEpochMilli(1L);
final Instant t2 = Instant.ofEpochMilli(2L);
final Instant t3 = Instant.ofEpochMilli(3L);
final Instant t4 = Instant.ofEpochMilli(4L);
final SecuritySource test = new VersionLockedSecuritySource(underlying, VersionCorrection.of(t1, t2));
Security result = Mockito.mock(Security.class);
Mockito.when(underlying.getSingle(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.of(t1, t2))).thenReturn(result);
assertSame(test.getSingle(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.LATEST), result);
assertSame(test.getSingle(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.ofVersionAsOf(t1)), result);
assertSame(test.getSingle(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.ofCorrectedTo(t2)), result);
result = Mockito.mock(Security.class);
Mockito.when(underlying.getSingle(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.of(t3, t2))).thenReturn(result);
assertSame(test.getSingle(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.ofVersionAsOf(t3)), result);
result = Mockito.mock(Security.class);
Mockito.when(underlying.getSingle(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.of(t1, t3))).thenReturn(result);
assertSame(test.getSingle(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.ofCorrectedTo(t3)), result);
result = Mockito.mock(Security.class);
Mockito.when(underlying.getSingle(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.of(t3, t4))).thenReturn(result);
assertSame(test.getSingle(ExternalId.of("Test", "Foo").toBundle(), VersionCorrection.of(t3, t4)), result);
}
示例4: test_get_ObjectId_VersionCorrection
import org.threeten.bp.Instant; //导入方法依赖的package包/类
public void test_get_ObjectId_VersionCorrection() {
final SecuritySource underlying = Mockito.mock(SecuritySource.class);
final Instant t1 = Instant.ofEpochMilli(1L);
final Instant t2 = Instant.ofEpochMilli(2L);
final Instant t3 = Instant.ofEpochMilli(3L);
final Instant t4 = Instant.ofEpochMilli(4L);
final SecuritySource test = new VersionLockedSecuritySource(underlying, VersionCorrection.of(t1, t2));
Security result = Mockito.mock(Security.class);
Mockito.when(underlying.get(ObjectId.of("Test", "Foo"), VersionCorrection.of(t1, t2))).thenReturn(result);
assertSame(test.get(ObjectId.of("Test", "Foo"), VersionCorrection.LATEST), result);
assertSame(test.get(ObjectId.of("Test", "Foo"), VersionCorrection.ofVersionAsOf(t1)), result);
assertSame(test.get(ObjectId.of("Test", "Foo"), VersionCorrection.ofCorrectedTo(t2)), result);
result = Mockito.mock(Security.class);
Mockito.when(underlying.get(ObjectId.of("Test", "Foo"), VersionCorrection.of(t3, t2))).thenReturn(result);
assertSame(test.get(ObjectId.of("Test", "Foo"), VersionCorrection.ofVersionAsOf(t3)), result);
result = Mockito.mock(Security.class);
Mockito.when(underlying.get(ObjectId.of("Test", "Foo"), VersionCorrection.of(t1, t3))).thenReturn(result);
assertSame(test.get(ObjectId.of("Test", "Foo"), VersionCorrection.ofCorrectedTo(t3)), result);
result = Mockito.mock(Security.class);
Mockito.when(underlying.get(ObjectId.of("Test", "Foo"), VersionCorrection.of(t3, t4))).thenReturn(result);
assertSame(test.get(ObjectId.of("Test", "Foo"), VersionCorrection.of(t3, t4)), result);
}
示例5: test_get_Collection_VersionCorrection
import org.threeten.bp.Instant; //导入方法依赖的package包/类
public void test_get_Collection_VersionCorrection() {
final SecuritySource underlying = Mockito.mock(SecuritySource.class);
final Instant t1 = Instant.ofEpochMilli(1L);
final Instant t2 = Instant.ofEpochMilli(2L);
final Instant t3 = Instant.ofEpochMilli(3L);
final Instant t4 = Instant.ofEpochMilli(4L);
final SecuritySource test = new VersionLockedSecuritySource(underlying, VersionCorrection.of(t1, t2));
Collection<ObjectId> ids = Arrays.asList(ObjectId.of("Test", "Foo"), ObjectId.of("Test", "Bar"));
Map<ObjectId, Security> result = ImmutableMap.<ObjectId, Security>of(ObjectId.of("Test", "Foo"), Mockito.mock(Security.class), ObjectId.of("Test", "Bar"), Mockito.mock(Security.class));
Mockito.when(underlying.get(ids, VersionCorrection.of(t1, t2))).thenReturn(result);
assertSame(test.get(ids, VersionCorrection.LATEST), result);
assertSame(test.get(ids, VersionCorrection.ofVersionAsOf(t1)), result);
assertSame(test.get(ids, VersionCorrection.ofCorrectedTo(t2)), result);
result = ImmutableMap.<ObjectId, Security>of(ObjectId.of("Test", "Foo"), Mockito.mock(Security.class), ObjectId.of("Test", "Bar"), Mockito.mock(Security.class));
Mockito.when(underlying.get(ids, VersionCorrection.of(t3, t2))).thenReturn(result);
assertSame(test.get(ids, VersionCorrection.ofVersionAsOf(t3)), result);
result = ImmutableMap.<ObjectId, Security>of(ObjectId.of("Test", "Foo"), Mockito.mock(Security.class), ObjectId.of("Test", "Bar"), Mockito.mock(Security.class));
Mockito.when(underlying.get(ids, VersionCorrection.of(t1, t3))).thenReturn(result);
assertSame(test.get(ids, VersionCorrection.ofCorrectedTo(t3)), result);
result = ImmutableMap.<ObjectId, Security>of(ObjectId.of("Test", "Foo"), Mockito.mock(Security.class), ObjectId.of("Test", "Bar"), Mockito.mock(Security.class));
Mockito.when(underlying.get(ids, VersionCorrection.of(t3, t4))).thenReturn(result);
assertSame(test.get(ids, VersionCorrection.of(t3, t4)), result);
}
示例6: test_get_Collection_VersionCorrection
import org.threeten.bp.Instant; //导入方法依赖的package包/类
public void test_get_Collection_VersionCorrection() {
final ConfigSource underlying = Mockito.mock(ConfigSource.class);
final Instant t1 = Instant.ofEpochMilli(1L);
final Instant t2 = Instant.ofEpochMilli(2L);
final Instant t3 = Instant.ofEpochMilli(3L);
final Instant t4 = Instant.ofEpochMilli(4L);
final ConfigSource test = new VersionLockedConfigSource(underlying, VersionCorrection.of(t1, t2));
Collection<ObjectId> ids = Arrays.asList(ObjectId.of("Test", "Foo"), ObjectId.of("Test", "Bar"));
Map<ObjectId, ConfigItem<?>> result = ImmutableMap.<ObjectId, ConfigItem<?>>of(ObjectId.of("Test", "Foo"), Mockito.mock(ConfigItem.class), ObjectId.of("Test", "Bar"),
Mockito.mock(ConfigItem.class));
Mockito.when(underlying.get(ids, VersionCorrection.of(t1, t2))).thenReturn(result);
assertSame(test.get(ids, VersionCorrection.LATEST), result);
assertSame(test.get(ids, VersionCorrection.ofVersionAsOf(t1)), result);
assertSame(test.get(ids, VersionCorrection.ofCorrectedTo(t2)), result);
result = ImmutableMap.<ObjectId, ConfigItem<?>>of(ObjectId.of("Test", "Foo"), Mockito.mock(ConfigItem.class), ObjectId.of("Test", "Bar"), Mockito.mock(ConfigItem.class));
Mockito.when(underlying.get(ids, VersionCorrection.of(t3, t2))).thenReturn(result);
assertSame(test.get(ids, VersionCorrection.ofVersionAsOf(t3)), result);
result = ImmutableMap.<ObjectId, ConfigItem<?>>of(ObjectId.of("Test", "Foo"), Mockito.mock(ConfigItem.class), ObjectId.of("Test", "Bar"), Mockito.mock(ConfigItem.class));
Mockito.when(underlying.get(ids, VersionCorrection.of(t1, t3))).thenReturn(result);
assertSame(test.get(ids, VersionCorrection.ofCorrectedTo(t3)), result);
result = ImmutableMap.<ObjectId, ConfigItem<?>>of(ObjectId.of("Test", "Foo"), Mockito.mock(ConfigItem.class), ObjectId.of("Test", "Bar"), Mockito.mock(ConfigItem.class));
Mockito.when(underlying.get(ids, VersionCorrection.of(t3, t4))).thenReturn(result);
assertSame(test.get(ids, VersionCorrection.of(t3, t4)), result);
}
示例7: testCreate
import org.threeten.bp.Instant; //导入方法依赖的package包/类
public void testCreate() {
final DynamicFunctionConfigurationSource source = new BeanDynamicFunctionConfigurationSource(DummyChangeManager.INSTANCE) {
@Override
protected boolean isPropogateEvent(ChangeEvent event) {
throw new UnsupportedOperationException();
}
@Override
protected VersionedFunctionConfigurationBean createConfiguration() {
return new Configuration();
}
};
final Instant t1 = Instant.ofEpochMilli(1L);
final Instant t2 = Instant.ofEpochMilli(2L);
final FunctionConfigurationBundle bundle1 = source.getFunctionConfiguration(t1);
assertEquals(((ParameterizedFunctionConfiguration) bundle1.getFunctions().get(0)).getParameter().get(0), VersionCorrection.of(t1, t1).toString());
final FunctionConfigurationBundle bundle2 = source.getFunctionConfiguration(t2);
assertEquals(((ParameterizedFunctionConfiguration) bundle2.getFunctions().get(0)).getParameter().get(0), VersionCorrection.of(t2, t2).toString());
}
示例8: test_getAll_Class_VersionCorrection
import org.threeten.bp.Instant; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes" })
public void test_getAll_Class_VersionCorrection() {
final ConfigSource underlying = Mockito.mock(ConfigSource.class);
final Instant t1 = Instant.ofEpochMilli(1L);
final Instant t2 = Instant.ofEpochMilli(2L);
final Instant t3 = Instant.ofEpochMilli(3L);
final Instant t4 = Instant.ofEpochMilli(4L);
final ConfigSource test = new VersionLockedConfigSource(underlying, VersionCorrection.of(t1, t2));
Collection result = Collections.singleton(Mockito.mock(ConfigItem.class));
Mockito.when(underlying.getAll(Convention.class, VersionCorrection.of(t1, t2))).thenReturn(result);
assertSame(test.getAll(Convention.class, VersionCorrection.LATEST), result);
assertSame(test.getAll(Convention.class, VersionCorrection.ofVersionAsOf(t1)), result);
assertSame(test.getAll(Convention.class, VersionCorrection.ofCorrectedTo(t2)), result);
result = Collections.singleton(Mockito.mock(ConfigItem.class));
Mockito.when(underlying.getAll(Convention.class, VersionCorrection.of(t3, t2))).thenReturn(result);
assertSame(test.getAll(Convention.class, VersionCorrection.ofVersionAsOf(t3)), result);
result = Collections.singleton(Mockito.mock(ConfigItem.class));
Mockito.when(underlying.getAll(Convention.class, VersionCorrection.of(t1, t3))).thenReturn(result);
assertSame(test.getAll(Convention.class, VersionCorrection.ofCorrectedTo(t3)), result);
result = Collections.singleton(Mockito.mock(ConfigItem.class));
Mockito.when(underlying.getAll(Convention.class, VersionCorrection.of(t3, t4))).thenReturn(result);
assertSame(test.getAll(Convention.class, VersionCorrection.of(t3, t4)), result);
}
示例9: test_getConfig_Class_ObjectId_VersionCorrection
import org.threeten.bp.Instant; //导入方法依赖的package包/类
public void test_getConfig_Class_ObjectId_VersionCorrection() {
final ConfigSource underlying = Mockito.mock(ConfigSource.class);
final Instant t1 = Instant.ofEpochMilli(1L);
final Instant t2 = Instant.ofEpochMilli(2L);
final Instant t3 = Instant.ofEpochMilli(3L);
final Instant t4 = Instant.ofEpochMilli(4L);
final ConfigSource test = new VersionLockedConfigSource(underlying, VersionCorrection.of(t1, t2));
Convention result = Mockito.mock(Convention.class);
Mockito.when(underlying.getConfig(Convention.class, ObjectId.of("Test", "Foo"), VersionCorrection.of(t1, t2))).thenReturn(result);
assertSame(test.getConfig(Convention.class, ObjectId.of("Test", "Foo"), VersionCorrection.LATEST), result);
assertSame(test.getConfig(Convention.class, ObjectId.of("Test", "Foo"), VersionCorrection.ofVersionAsOf(t1)), result);
assertSame(test.getConfig(Convention.class, ObjectId.of("Test", "Foo"), VersionCorrection.ofCorrectedTo(t2)), result);
result = Mockito.mock(Convention.class);
Mockito.when(underlying.getConfig(Convention.class, ObjectId.of("Test", "Foo"), VersionCorrection.of(t3, t2))).thenReturn(result);
assertSame(test.getConfig(Convention.class, ObjectId.of("Test", "Foo"), VersionCorrection.ofVersionAsOf(t3)), result);
result = Mockito.mock(Convention.class);
Mockito.when(underlying.getConfig(Convention.class, ObjectId.of("Test", "Foo"), VersionCorrection.of(t1, t3))).thenReturn(result);
assertSame(test.getConfig(Convention.class, ObjectId.of("Test", "Foo"), VersionCorrection.ofCorrectedTo(t3)), result);
result = Mockito.mock(Convention.class);
Mockito.when(underlying.getConfig(Convention.class, ObjectId.of("Test", "Foo"), VersionCorrection.of(t3, t4))).thenReturn(result);
assertSame(test.getConfig(Convention.class, ObjectId.of("Test", "Foo"), VersionCorrection.of(t3, t4)), result);
}
示例10: testDynamicRepository
import org.threeten.bp.Instant; //导入方法依赖的package包/类
public void testDynamicRepository() {
final FunctionConfigurationSource configSource = Mockito.mock(FunctionConfigurationSource.class);
final FunctionRepositoryFactory instance = FunctionRepositoryFactory.constructRepositoryFactory(configSource);
final Instant t1 = Instant.ofEpochMilli(1L);
final Instant t2 = Instant.ofEpochMilli(2L);
final Instant t3 = Instant.ofEpochMilli(3L);
final FunctionConfigurationBundle configuration1 = new FunctionConfigurationBundle();
final FunctionConfigurationBundle configuration2 = new FunctionConfigurationBundle();
configuration2.addFunctions(new ParameterizedFunctionConfiguration(MockSingleArgumentFunction.class.getName(), Collections.singleton("foo")));
Mockito.when(configSource.getFunctionConfiguration(t1)).thenReturn(configuration1);
Mockito.when(configSource.getFunctionConfiguration(t2)).thenReturn(configuration1);
Mockito.when(configSource.getFunctionConfiguration(t3)).thenReturn(configuration2);
final FunctionRepository repo1 = instance.constructRepository(t1);
final FunctionRepository repo2 = instance.constructRepository(t2);
assertEquals(repo1.getAllFunctions().size(), FunctionRepositoryFactory.INTRINSIC_FUNCTION_COUNT);
assertSame(repo1, repo2);
final FunctionRepository repo3 = instance.constructRepository(t3);
assertEquals(repo3.getAllFunctions().size(), FunctionRepositoryFactory.INTRINSIC_FUNCTION_COUNT + 1);
}
示例11: getSubscriptionTrace
import org.threeten.bp.Instant; //导入方法依赖的package包/类
@Override
public SubscriptionTrace getSubscriptionTrace(String identifier) {
if (_securityUniqueId2Subscription.containsKey(identifier)) {
Subscription sub = _securityUniqueId2Subscription.get(identifier);
Date creationTime = sub.getCreationTime();
Instant instant = Instant.ofEpochMilli(creationTime.getTime());
Set<DistributorTrace> distributors = new HashSet<>();
for (MarketDataDistributor distributor : sub.getDistributors()) {
distributors.add(new DistributorTrace(
distributor.getDistributionSpec().getJmsTopic(),
Instant.ofEpochMilli(distributor.getExpiry()).toString(),
distributor.hasExpired(),
distributor.isPersistent(),
distributor.getNumMessagesSent()));
}
return new SubscriptionTrace(identifier, instant.toString(), distributors, sub.getLiveDataHistory().getLastKnownValues().toString());
} else {
return new SubscriptionTrace(identifier);
}
}
示例12: buildSecurityDirectory
import org.threeten.bp.Instant; //导入方法依赖的package包/类
/**
* @param buid
* @param tickMsgList
* @return
*/
private File buildSecurityDirectory(String buid, long receivedTS) {
Instant instant = Instant.ofEpochMilli(receivedTS);
ZonedDateTime dateTime = ZonedDateTime.ofInstant(instant, ZoneOffset.UTC);
LocalDate today = dateTime.toLocalDate();
StringBuilder buf = new StringBuilder();
buf.append(_rootDir).append(File.separator);
buf.append(buid).append(File.separator).append(today.getYear()).append(File.separator);
int month = today.getMonthValue();
if (month < 10) {
buf.append("0").append(month);
} else {
buf.append(month);
}
buf.append(File.separator);
int dayOfMonth = today.getDayOfMonth();
if (dayOfMonth < 10) {
buf.append("0").append(dayOfMonth);
} else {
buf.append(dayOfMonth);
}
buf.append(File.separator);
return new File(buf.toString());
}
示例13: isSmsSentOneHourAgo
import org.threeten.bp.Instant; //导入方法依赖的package包/类
public static boolean isSmsSentOneHourAgo(Context context) {
Long smsSentEpoch = CRDSharedPreferences.getInstance(context).getSendingSmsEpoch();
if (smsSentEpoch == null) {
return false;
}
Instant oneHourAgo = getNowTime().toInstant().minus(Duration.ofHours(1));
Instant smsSentInstant = Instant.ofEpochMilli(smsSentEpoch);
return smsSentInstant.isAfter(oneHourAgo) && smsSentInstant.isBefore(getNowTime().toInstant());
}
示例14: nextExecutionInMillis
import org.threeten.bp.Instant; //导入方法依赖的package包/类
@Override
public long nextExecutionInMillis(long currentTimeInMillis, int executionsCount, Long lastExecutionTimeInMillis) {
Instant currentInstant = Instant.ofEpochMilli(currentTimeInMillis);
return cronExpression.timeToNextExecution(ZonedDateTime.ofInstant(
currentInstant,
ZoneId.systemDefault()
))
.transform(durationBetweenNextExecution ->
currentInstant.plus(durationBetweenNextExecution).toEpochMilli()
)
.or(Schedule.WILL_NOT_BE_EXECUTED_AGAIN);
}
示例15: timestamp
import org.threeten.bp.Instant; //导入方法依赖的package包/类
private static Instant timestamp(final Iterable<URL> urls) {
long ctime = 0;
for (URL url : urls) {
try {
final File f = new File(url.toURI());
final long l = f.lastModified();
if (l > ctime) {
ctime = l;
}
} catch (URISyntaxException e) {
// Ignore this one
}
}
return Instant.ofEpochMilli(ctime);
}