当前位置: 首页>>代码示例>>Java>>正文


Java Instant.now方法代码示例

本文整理汇总了Java中org.threeten.bp.Instant.now方法的典型用法代码示例。如果您正苦于以下问题:Java Instant.now方法的具体用法?Java Instant.now怎么用?Java Instant.now使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.threeten.bp.Instant的用法示例。


在下文中一共展示了Instant.now方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPortfolioResolution

import org.threeten.bp.Instant; //导入方法依赖的package包/类
public void testPortfolioResolution() {
  TestLifecycle.begin();
  try {
    ViewDefinition viewDefinition = new ViewDefinition("Test 1", UniqueId.of("Portfolio", "Test"), UserPrincipal.getTestUser());
    ViewCalculationConfiguration calcConfig = new ViewCalculationConfiguration(viewDefinition, "Default");
    SimpleRequirementAmbiguityChecker checker = new SimpleRequirementAmbiguityChecker(context(), Instant.now(), VersionCorrection.LATEST, calcConfig);
    // Resolved the portfolio
    assertEquals(checker.getCompilationContext().getPortfolio().getUniqueId(), portfolio().getUniqueId());
    viewDefinition = new ViewDefinition("Test 2", UniqueId.of("Portfolio", "Missing", "1"), UserPrincipal.getTestUser());
    calcConfig = new ViewCalculationConfiguration(viewDefinition, "Default");
    checker = new SimpleRequirementAmbiguityChecker(context(), Instant.now(), VersionCorrection.LATEST, calcConfig);
    // Portfolio id not found
    assertEquals(checker.getCompilationContext().getPortfolio(), null);
    viewDefinition = new ViewDefinition("Test 3", UserPrincipal.getTestUser());
    calcConfig = new ViewCalculationConfiguration(viewDefinition, "Default");
    checker = new SimpleRequirementAmbiguityChecker(context(), Instant.now(), VersionCorrection.LATEST, calcConfig);
    // No portfolio requested
    assertEquals(checker.getCompilationContext().getPortfolio(), null);
  } finally {
    TestLifecycle.end();
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:23,代码来源:SimpleRequirementAmbiguityCheckerTest.java

示例2: setUpClass

import org.threeten.bp.Instant; //导入方法依赖的package包/类
@BeforeMethod
public void setUpClass()  {
  FunctionModelConfig config = CreditPricingSampleData.createYCMappingFunctionModelConfig();
  ImmutableMap<Class<?>, Object> components = InterestRateMockSources.generateBaseComponents();
  VersionCorrectionProvider vcProvider = new FixedInstantVersionCorrectionProvider(Instant.now());
  ServiceContext serviceContext = ServiceContext.of(components).with(VersionCorrectionProvider.class, vcProvider);
  ThreadLocalServiceContext.init(serviceContext);
  ComponentMap componentMap = ComponentMap.of(components);
  EmptyMarketDataFactory dataFactory = new EmptyMarketDataFactory();
  MarketDataEnvironmentFactory environmentFactory =
      new MarketDataEnvironmentFactory(dataFactory,
                                       MarketDataBuilders.creditCurve(),
                                       MarketDataBuilders.isdaYieldCurve());
  _functionRunner = new FunctionRunner(environmentFactory);
  _pvFunction = FunctionModel.build(DefaultCreditPvFn.class, config, componentMap);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:17,代码来源:MappingIsdaCompliantYieldCurveFnTest.java

示例3: add

import org.threeten.bp.Instant; //导入方法依赖的package包/类
@Override
public synchronized YieldCurveDefinitionDocument add(YieldCurveDefinitionDocument document) {
  ArgumentChecker.notNull(document, "document");
  ArgumentChecker.notNull(document.getYieldCurveDefinition(), "document.yieldCurveDefinition");
  final Currency currency = document.getYieldCurveDefinition().getCurrency();
  final String name = document.getYieldCurveDefinition().getName();
  final Pair<Currency, String> key = Pairs.of(currency, name);
  if (_definitions.containsKey(key)) {
    throw new IllegalArgumentException("Duplicate definition");
  }
  final TreeMap<Instant, YieldCurveDefinition> value = new TreeMap<Instant, YieldCurveDefinition>();
  Instant now = Instant.now();
  value.put(now, document.getYieldCurveDefinition());
  _definitions.put(key, value);
  final UniqueId uid = UniqueId.of(getUniqueIdScheme(), name + "_" + currency.getCode());
  document.setUniqueId(uid);
  changeManager().entityChanged(ChangeType.ADDED, document.getObjectId(), document.getVersionFromInstant(), document.getVersionToInstant(), now);
  return document;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:20,代码来源:InMemoryInterpolatedYieldCurveDefinitionMaster.java

示例4: preExecute

import org.threeten.bp.Instant; //导入方法依赖的package包/类
/**
 * Prepares the cycle for execution, organising the caches and copying any values salvaged from a previous cycle.
 * 
 * @param previousCycle the previous cycle from which a delta cycle should be performed, or null to perform a full cycle
 * @param marketDataSnapshot the market data snapshot with which to execute the cycle, not null
 * @param suppressExecutionOnNoMarketData true if execution is to be suppressed when input data is entirely missing, false otherwise
 * @return true if execution should continue, false if execution should be suppressed
 */
public boolean preExecute(final SingleComputationCycle previousCycle, final MarketDataSnapshot marketDataSnapshot, final boolean suppressExecutionOnNoMarketData) {
  if (_state != ViewCycleState.AWAITING_EXECUTION) {
    throw new IllegalStateException("State must be " + ViewCycleState.AWAITING_EXECUTION);
  }
  _startTime = Instant.now();
  _state = ViewCycleState.EXECUTING;
  createAllCaches();
  if (!prepareInputs(marketDataSnapshot, suppressExecutionOnNoMarketData)) {
    generateSuppressedOutputs();
    return false;
  }
  if (previousCycle != null) {
    computeDelta(previousCycle);
  }
  return true;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:25,代码来源:SingleComputationCycle.java

示例5: test_remove_removed

import org.threeten.bp.Instant; //导入方法依赖的package包/类
@Test
public void test_remove_removed() {
  Instant now = Instant.now(_lenMaster.getClock());

  UniqueId uniqueId = UniqueId.of("DbLen", "101", "0");
  _lenMaster.remove(uniqueId);
  LegalEntityDocument test = _lenMaster.get(uniqueId);

  assertEquals(uniqueId, test.getUniqueId());
  assertEquals(_version1Instant, test.getVersionFromInstant());
  assertEquals(now, test.getVersionToInstant());
  assertEquals(_version1Instant, test.getCorrectionFromInstant());
  assertEquals(null, test.getCorrectionToInstant());
  ManageableLegalEntity legalEntity = test.getLegalEntity();
  assertNotNull(legalEntity);
  assertEquals(uniqueId, legalEntity.getUniqueId());
  assertEquals("TestLegalEntity101", legalEntity.getName());
  assertEquals(ExternalIdBundle.of(ExternalId.of("A", "B"), ExternalId.of("C", "D"), ExternalId.of("E", "F")), legalEntity.getExternalIdBundle());
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:20,代码来源:ModifyDbLegalEntityBeanMasterTest.java

示例6: run

import org.threeten.bp.Instant; //导入方法依赖的package包/类
@Override
public void run() {
  if (cancelled.get()) {
    return;
  }

  try {
    task.run();
  } catch(Exception e) {
    LOGGER.warn(format("Execution of task %s failed", task.toString()), e);
  }
  lastRun = Instant.now();
  scheduleNext();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:15,代码来源:LocalSchedulerService.java

示例7: testPrimitivesOnlyNoPortfolioReference

import org.threeten.bp.Instant; //导入方法依赖的package包/类
public void testPrimitivesOnlyNoPortfolioReference() {
  TestLifecycle.begin();
  try {
    final ViewDefinition viewDefinition = new ViewDefinition("Test", "jonathan");
    final ViewCalculationConfiguration calcConfig = new ViewCalculationConfiguration(viewDefinition, "Config1");
    viewDefinition.addViewCalculationConfiguration(calcConfig);
    final UniqueId t1 = UniqueId.of("TestScheme", "t1");
    final InMemoryFunctionRepository functionRepo = new InMemoryFunctionRepository();
    final MockFunction f1 = MockFunction.getMockFunction(new ComputationTarget(ComputationTargetType.PRIMITIVE, t1), 42);
    functionRepo.addFunction(f1);
    final FunctionCompilationContext compilationContext = new FunctionCompilationContext();
    compilationContext.setFunctionInitId(123);
    final CompiledFunctionService cfs = new CompiledFunctionService(functionRepo, new CachingFunctionRepositoryCompiler(), compilationContext);
    TestLifecycle.register(cfs);
    cfs.initialize();
    final DefaultFunctionResolver functionResolver = new DefaultFunctionResolver(cfs);
    final DefaultCachingComputationTargetResolver computationTargetResolver = new DefaultCachingComputationTargetResolver(new DefaultComputationTargetResolver(), _cacheManager);
    compilationContext.setRawComputationTargetResolver(computationTargetResolver);
    final ViewCompilationServices compilationServices = new ViewCompilationServices(new FixedMarketDataAvailabilityProvider(), functionResolver, compilationContext,
        cfs.getExecutorService(), new DependencyGraphBuilderFactory());
    // We'll require r1 which can be satisfied by f1
    calcConfig.addSpecificRequirement(f1.getResultSpec().toRequirementSpecification());
    final Instant now = Instant.now();
    final CompiledViewDefinitionWithGraphsImpl compiledViewDefinition = ViewDefinitionCompiler.compile(viewDefinition, compilationServices, now, VersionCorrection.of(now, now));
    assertTrue(compiledViewDefinition.getMarketDataRequirements().isEmpty());
    assertEquals(1, compiledViewDefinition.getDependencyGraphExplorers().size());
    assertNotNull(compiledViewDefinition.getDependencyGraphExplorer("Config1"));
    assertTargets(compiledViewDefinition, t1);
  } finally {
    TestLifecycle.end();
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:33,代码来源:ViewDefinitionCompilerTest.java

示例8: setUpClass

import org.threeten.bp.Instant; //导入方法依赖的package包/类
@BeforeClass
private void setUpClass() {

  ZonedDateTime valTime = LocalDate.of(2014, 6, 1).atStartOfDay(ZoneOffset.UTC);
  MarketDataBundle marketDataBundle = new MapMarketDataBundle(InterestRateMockSources.createMarketDataEnvironment());
  _environment = new SimpleEnvironment(valTime, marketDataBundle);
  VersionCorrectionProvider vcProvider = new FixedInstantVersionCorrectionProvider(Instant.now());
  ServiceContext serviceContext = ServiceContext.of(_components).with(VersionCorrectionProvider.class, vcProvider);
  ThreadLocalServiceContext.init(serviceContext);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:11,代码来源:ExposureFunctionTest.java

示例9: test_ReplaceVersions2

import org.threeten.bp.Instant; //导入方法依赖的package包/类
@Test
public void test_ReplaceVersions2() {
  Clock origClock = _cfgMaster.getClock();
  try {
    Instant now = Instant.now();

    ObjectId baseOid = setupTestData(now);
    _cfgMaster.setClock(Clock.fixed(now.plus(2, HOURS), ZoneOffset.UTC));
    ConfigDocument latestDoc = _cfgMaster.get(baseOid, VersionCorrection.LATEST);
    Instant latestFrom = latestDoc.getVersionFromInstant();


    List<ConfigDocument> replacement = newArrayList();
    for (int i = 0; i <= 10; i++) {
      String val = "test" + i;
      ConfigDocument doc = new ConfigDocument(ConfigItem.of(val, "some_name_"+i));
      doc.setVersionFromInstant(latestFrom.plus(i - 3, MINUTES));
      replacement.add(doc);
    }

    _cfgMaster.replaceVersions(latestDoc, replacement);

    ConfigHistoryRequest<String> historyRequest = new ConfigHistoryRequest<String>();
    historyRequest.setObjectId(baseOid);
    historyRequest.setCorrectionsFromInstant(now.plus(2, HOURS));
    ConfigHistoryResult<String> result = _cfgMaster.history(historyRequest);
    List<ConfigDocument> confDocs = result.getDocuments();

    assertEquals(12, confDocs.size());

  } finally {
    _cfgMaster.setClock(origClock);
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:35,代码来源:ModifyConfigDbConfigMasterWorkerReplaceVersionTest.java

示例10: test_add_add

import org.threeten.bp.Instant; //导入方法依赖的package包/类
@Test
public void test_add_add() {
  Instant now = Instant.now(_posMaster.getClock());
  
  ManageablePosition position = new ManageablePosition(BigDecimal.TEN, ExternalId.of("A", "B"));
  PositionDocument doc = new PositionDocument();
  doc.setPosition(position);
  PositionDocument test = _posMaster.add(doc);
  
  UniqueId uniqueId = test.getUniqueId();
  assertNotNull(uniqueId);
  assertEquals("DbPos", uniqueId.getScheme());
  assertTrue(uniqueId.isVersioned());
  assertTrue(Long.parseLong(uniqueId.getValue()) >= 1000);
  assertEquals("0", uniqueId.getVersion());
  assertEquals(now, test.getVersionFromInstant());
  assertEquals(null, test.getVersionToInstant());
  assertEquals(now, test.getCorrectionFromInstant());
  assertEquals(null, test.getCorrectionToInstant());
  ManageablePosition testPosition = test.getPosition();
  assertNotNull(testPosition);
  assertEquals(uniqueId, testPosition.getUniqueId());
  assertEquals(BigDecimal.TEN, testPosition.getQuantity());
  ExternalIdBundle secKey = testPosition.getSecurityLink().getExternalId();
  assertEquals(1, secKey.size());
  assertTrue(secKey.getExternalIds().contains(ExternalId.of("A", "B")));
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:28,代码来源:ModifyPositionDbPositionMasterWorkerAddPositionTest.java

示例11: test_update_getUpdateGet

import org.threeten.bp.Instant; //导入方法依赖的package包/类
@Test
public void test_update_getUpdateGet() {
  Instant now = Instant.now(_secMaster.getClock());
  
  UniqueId uniqueId = UniqueId.of("DbSec", "101", "0");
  SecurityDocument base = _secMaster.get(uniqueId);
  ManageableSecurity security = new ManageableSecurity(uniqueId, "Name", "Type", ExternalIdBundle.of("A", "B"));
  SecurityDocument input = new SecurityDocument(security);
  
  SecurityDocument updated = _secMaster.update(input);
  assertEquals(false, base.getUniqueId().equals(updated.getUniqueId()));
  assertEquals(now, updated.getVersionFromInstant());
  assertEquals(null, updated.getVersionToInstant());
  assertEquals(now, updated.getCorrectionFromInstant());
  assertEquals(null, updated.getCorrectionToInstant());
  assertEquals(input.getSecurity(), updated.getSecurity());
  
  SecurityDocument old = _secMaster.get(uniqueId);
  assertEquals(base.getUniqueId(), old.getUniqueId());
  assertEquals(base.getVersionFromInstant(), old.getVersionFromInstant());
  assertEquals(now, old.getVersionToInstant());  // old version ended
  assertEquals(base.getCorrectionFromInstant(), old.getCorrectionFromInstant());
  assertEquals(base.getCorrectionToInstant(), old.getCorrectionToInstant());
  assertEquals(base.getSecurity(), old.getSecurity());
  
  SecurityHistoryRequest search = new SecurityHistoryRequest(base.getUniqueId(), null, now);
  search.setFullDetail(false);
  SecurityHistoryResult searchResult = _secMaster.history(search);
  assertEquals(2, searchResult.getDocuments().size());
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:31,代码来源:ModifySecurityDbSecurityMasterWorkerUpdateTest.java

示例12: test_ReplaceVersions

import org.threeten.bp.Instant; //导入方法依赖的package包/类
@Test
public void test_ReplaceVersions() {
  Clock origClock = _cfgMaster.getClock();
  try {
    Instant now = Instant.now();

    ObjectId baseOid = setupTestData(now);
    _cfgMaster.setClock(Clock.fixed(now.plus(2, HOURS), ZoneOffset.UTC));
    ConfigDocument latestDoc = _cfgMaster.get(baseOid, VersionCorrection.LATEST);
    Instant latestFrom = latestDoc.getVersionFromInstant();

    List<ConfigDocument> replacement = newArrayList();
    for (int i = 0; i <= 10; i++) {
      String val = "test" + i;
      ConfigDocument doc = new ConfigDocument(ConfigItem.of(val, "some_name_"+i));
      doc.setVersionFromInstant(latestFrom.plus(i, SECONDS));
      replacement.add(doc);
    }

    _cfgMaster.replaceVersions(latestDoc, replacement);

    ConfigHistoryRequest<String> historyRequest = new ConfigHistoryRequest<String>();
    historyRequest.setObjectId(baseOid);
    historyRequest.setCorrectionsFromInstant(now.plus(2, HOURS));
    ConfigHistoryResult<String> result = _cfgMaster.history(historyRequest);
    List<ConfigDocument> values = result.getDocuments();

    assertEquals(15, values.size());

  } finally {
    _cfgMaster.setClock(origClock);
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:34,代码来源:ModifyConfigDbConfigMasterWorkerReplaceVersionsTest.java

示例13: test_ReplaceVersions

import org.threeten.bp.Instant; //导入方法依赖的package包/类
@Test
public void test_ReplaceVersions() {
  Clock origClock = _cfgMaster.getClock();
  try {
    Instant now = Instant.now();

    ObjectId baseOid = setupTestData(now);
    _cfgMaster.setClock(Clock.fixed(now.plus(2, HOURS), ZoneOffset.UTC));
    ConfigDocument latestDoc = _cfgMaster.get(baseOid, VersionCorrection.LATEST);
    Instant latestFrom = latestDoc.getVersionFromInstant();


    List<ConfigDocument> replacement = newArrayList();
    for (int i = 0; i <= 10; i++) {
      String val = "test" + i;
      ConfigDocument doc = new ConfigDocument(ConfigItem.of(val, "some_name_"+i));
      doc.setVersionFromInstant(latestFrom.plus(i, SECONDS));
      replacement.add(doc);
    }

    _cfgMaster.replaceVersions(latestDoc, replacement);

    ConfigHistoryRequest<String> historyRequest = new ConfigHistoryRequest<String>();
    historyRequest.setObjectId(baseOid);
    historyRequest.setCorrectionsFromInstant(now.plus(2, HOURS));
    ConfigHistoryResult<String> result = _cfgMaster.history(historyRequest);
    List<ConfigDocument> confDocs = result.getDocuments();

    assertEquals(15, confDocs.size());

  } finally {
    _cfgMaster.setClock(origClock);
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:35,代码来源:ModifyConfigDbConfigMasterWorkerReplaceVersionTest.java

示例14: test_ReplaceVersions2

import org.threeten.bp.Instant; //导入方法依赖的package包/类
@Test
public void test_ReplaceVersions2() {
  Clock origClock = _exgMaster.getClock();
  try {
    Instant now = Instant.now();

    ObjectId baseOid = setupTestData(now);
    _exgMaster.setClock(Clock.fixed(now.plus(2, HOURS), ZoneOffset.UTC));
    ExchangeDocument latestDoc = _exgMaster.get(baseOid, VersionCorrection.LATEST);
    Instant latestFrom = latestDoc.getVersionFromInstant();

    final ExternalIdBundle bundle = ExternalIdBundle.of("B", "B0");
    final ExternalIdBundle region = ExternalIdBundle.of("R", "R0");
    List<ExchangeDocument> replacement = newArrayList();
    for (int i = 0; i <= 10; i++) {
      ManageableExchange ex = new ManageableExchange(bundle, "test" + i, region, null);
      ExchangeDocument doc = new ExchangeDocument(ex);
      doc.setVersionFromInstant(latestFrom.plus(i - 3, MINUTES));
      replacement.add(doc);
    }

    _exgMaster.replaceVersions(latestDoc, replacement);

    ExchangeHistoryRequest historyRequest = new ExchangeHistoryRequest();
    historyRequest.setObjectId(baseOid);
    historyRequest.setCorrectionsFromInstant(now.plus(2, HOURS));
    ExchangeHistoryResult result = _exgMaster.history(historyRequest);
    List<ExchangeDocument> exchanges = result.getDocuments();

    assertEquals(12, exchanges.size());

  } finally {
    _exgMaster.setClock(origClock);
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:36,代码来源:ModifyExchangeDbExchangeMasterWorkerReplaceVersionTest.java

示例15: getPortfolioOutputs

import org.threeten.bp.Instant; //导入方法依赖的package包/类
@Override
public AvailableOutputs getPortfolioOutputs(Portfolio portfolio, final Instant instant, final Integer maxNodes, final Integer maxPositions) {
  portfolio = preparePortfolio(portfolio, maxNodes, maxPositions);
  final Instant compileInstant = (instant != null ? instant : Instant.now());
  final CompiledFunctionRepository functionRepository = getCompiledFunctionService().compileFunctionRepository(compileInstant);
  return new AvailablePortfolioOutputs(portfolio, functionRepository, getFunctionExclusionGroups(), getMarketDataAvailability(), getWildcardIndicator());
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:8,代码来源:DefaultAvailableOutputsProvider.java


注:本文中的org.threeten.bp.Instant.now方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。