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


Java Instant类代码示例

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


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

示例1: testIsoStringToDateMillis

import org.threeten.bp.Instant; //导入依赖的package包/类
@Test
public void testIsoStringToDateMillis() {
	String input = "2017-02-13T12:34:56.789Z";		
	Date expected = DateTimeUtils.toDate(Instant.parse("2017-02-13T12:34:56.789Z"));
	
	assertEquals(expected, ValueConversionUtil.isoStringToDate(input));
}
 
开发者ID:innodev-au,项目名称:wmboost-data,代码行数:8,代码来源:ValueConversionUtilTest.java

示例2: newInfo

import org.threeten.bp.Instant; //导入依赖的package包/类
protected AccelerationData.Info newInfo(final Materialization materialization) {
  final com.dremio.service.accelerator.proto.JobDetails details = materialization.getJob();
  final Long jobStart = details.getJobStart();
  final Long jobEnd = details.getJobEnd();

  final AccelerationData.Info info = new AccelerationData.Info();
  if (jobStart != null) {
    info.setStart(DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.ofInstant(Instant.ofEpochMilli(jobStart), ZoneOffset.UTC)));
  }
  if (jobEnd != null) {
    info.setEnd(DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.ofInstant(Instant.ofEpochMilli(jobEnd), ZoneOffset.UTC)));
  }

  if (jobStart != null && jobEnd != null) {
    final Duration duration = Duration.ofMillis(jobEnd - jobStart);
    info.setDuration(DateTimeFormatter.ISO_LOCAL_TIME.format(LocalTime.MIDNIGHT.plus(duration)));
  }

  info.setJobId(details.getJobId())
    .setInputBytes(details.getInputBytes())
    .setInputRecords(details.getInputRecords())
    .setOutputBytes(details.getOutputBytes())
    .setOutputRecords(details.getOutputRecords());

  return info;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:27,代码来源:DatasetsResource.java

示例3: canCreateStringMapFromObjectMap

import org.threeten.bp.Instant; //导入依赖的package包/类
public void canCreateStringMapFromObjectMap() {
    Map<String, ?> objectMap = ImmutableMap.of(
            "key1", 12,
            "key2", Instant.ofEpochMilli(72),
            "key3", ImmutableMap.of("hello", "goodbye"),
            "key4", ImmutableList.of("one", "two", "three"),
            "key5", DeserializationMode.ENTITY
    );

    Map<String, String> stringMap = CloudApiUtils.asStringMap(objectMap);

    String expected = "{key1=12, key2=1970-01-01T00:00:00.072Z, key3=hello: goodbye, key4=one, two, three, key5=ENTITY}";
    @SuppressWarnings("unchecked")
    String actual = StringUtils.join(stringMap);

    assertEquals(actual, expected, "We should be able to transparently "
            + "convert object maps to string maps");
}
 
开发者ID:joyent,项目名称:java-triton,代码行数:19,代码来源:CloudApiUtilsTest.java

示例4: getCurveSpecification

import org.threeten.bp.Instant; //导入依赖的package包/类
/**
 * Creates a {@link CurveSpecification}.
 *
 * @param valuationTime The valuation time
 * @param curveDate The curve date
 * @param curveDefinition The curve definition
 * @return The curve specification
 */
private CurveSpecification getCurveSpecification(final Instant valuationTime, final LocalDate curveDate, final CurveDefinition curveDefinition) {
  final Map<String, CurveNodeIdMapper> cache = new HashMap<>();
  final Collection<CurveNodeWithIdentifier> identifiers = new ArrayList<>();
  final String curveName = curveDefinition.getName();
  for (final CurveNode node : curveDefinition.getNodes()) {
    final String curveSpecificationName = node.getCurveNodeIdMapperName();
    final CurveNodeIdMapper builderConfig = getCurveNodeIdMapper(valuationTime, cache, curveSpecificationName);
    if (builderConfig == null) {
      throw new OpenGammaRuntimeException("Could not get curve node id mapper " + curveSpecificationName + " for curve named " + curveName);
    }
    final CurveNodeWithIdentifierBuilder identifierBuilder = new CurveNodeWithIdentifierBuilder(curveDate, builderConfig);
    identifiers.add(node.accept(identifierBuilder));
  }
  return new CurveSpecification(curveDate, curveName, identifiers);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:24,代码来源:ConfigDBCurveSpecificationBuilder.java

示例5: 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

示例6: test_add_add

import org.threeten.bp.Instant; //导入依赖的package包/类
@Test
public void test_add_add() {
  Instant now = Instant.now(_cfgMaster.getClock());
  
  ConfigItem<ExternalId> item = ConfigItem.of(ExternalId.of("A", "B"));
  item.setName("TestConfig");
  ConfigDocument test = _cfgMaster.add(new ConfigDocument(item));
  
  UniqueId uniqueId = test.getUniqueId();
  assertNotNull(uniqueId);
  assertEquals("DbCfg", 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());
  assertEquals(ExternalId.of("A", "B"), test.getConfig().getValue());
  assertEquals("TestConfig", test.getName());
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:22,代码来源:ModifyConfigDbConfigMasterWorkerAddTest.java

示例7: compile

import org.threeten.bp.Instant; //导入依赖的package包/类
@Override
public CompiledFunctionDefinition compile(final FunctionCompilationContext context, final Instant atInstant) {
  return new BondTotalReturnSwapCompiledFunction(getTargetToDefinitionConverter(context), getDefinitionToDerivativeConverter(context), true) {

    @Override
    protected Set<ComputedValue> getValues(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target,
        final Set<ValueRequirement> desiredValues, final InstrumentDerivative derivative, final FXMatrix fxMatrix) {
      final ValueProperties properties = Iterables.getOnlyElement(desiredValues).getConstraints().copy().get();
      final ValueSpecification spec = new ValueSpecification(GAMMA_PV01, target.toSpecification(), properties);
      final IssuerProviderInterface issuerCurves = getMergedWithIssuerProviders(inputs, fxMatrix);
      final Double gammaPV01 = derivative.accept(BondBillTrsGammaPV01Calculator.getInstance(), issuerCurves);
      return Collections.singleton(new ComputedValue(spec, gammaPV01));
    }

    @Override
    protected String getCurrencyOfResult(final BondTotalReturnSwapSecurity security) {
      return security.getNotionalCurrency().getCode();
    }
  };
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:21,代码来源:BondTotalReturnSwapGammaPV01Function.java

示例8: test_remove_removed

import org.threeten.bp.Instant; //导入依赖的package包/类
@Test
public void test_remove_removed() {
  Instant now = Instant.now(_secMaster.getClock());
  
  UniqueId uniqueId = UniqueId.of("DbSec", "101", "0");
  _secMaster.remove(uniqueId);
  SecurityDocument test = _secMaster.get(uniqueId);
  
  assertEquals(uniqueId, test.getUniqueId());
  assertEquals(_version1Instant, test.getVersionFromInstant());
  assertEquals(now, test.getVersionToInstant());
  assertEquals(_version1Instant, test.getCorrectionFromInstant());
  assertEquals(null, test.getCorrectionToInstant());
  ManageableSecurity security = test.getSecurity();
  assertNotNull(security);
  assertEquals(uniqueId, security.getUniqueId());
  assertEquals("TestSecurity101", security.getName());
  assertEquals("EQUITY", security.getSecurityType());
  assertEquals(ExternalIdBundle.of(ExternalId.of("A", "B"), ExternalId.of("C", "D"), ExternalId.of("E", "F")), security.getExternalIdBundle());
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:21,代码来源:ModifyDbSecurityBeanMasterTest.java

示例9: 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);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:23,代码来源:VersionLockedSecuritySourceTest.java

示例10: init

import org.threeten.bp.Instant; //导入依赖的package包/类
@Override
public void init(Set<ValueSpecification> values, long timeout, TimeUnit ucUnit) {
  Instant start = OpenGammaClock.getInstance().instant();
  TemporalUnit unit = convertUnit(ucUnit);
  Duration remaining = Duration.of(timeout, unit);

  _historicalSnapshot1.init(values, timeout, ucUnit);
  Instant after1 = OpenGammaClock.getInstance().instant();
  Duration duration1 = Duration.between(start, after1);
  remaining = remaining.minus(duration1);
  if (remaining.isNegative()) {
    return;
  }
  _historicalSnapshot2.init(values, remaining.get(unit), ucUnit);
  Instant after2 = OpenGammaClock.getInstance().instant();
  Duration duration2 = Duration.between(after1, after2);
  remaining = remaining.minus(duration2);
  if (remaining.isNegative()) {
    return;
  }
  _baseSnapshot.init(values, remaining.get(unit), ucUnit);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:23,代码来源:HistoricalShockMarketDataSnapshot.java

示例11: compile

import org.threeten.bp.Instant; //导入依赖的package包/类
@Override
public CompiledFunctionDefinition compile(final FunctionCompilationContext context, final Instant atInstant) {
  final HolidaySource holidaySource = OpenGammaCompilationContext.getHolidaySource(context);
  final RegionSource regionSource = OpenGammaCompilationContext.getRegionSource(context);
  final SecuritySource securitySource = OpenGammaCompilationContext.getSecuritySource(context);
  final ConventionBundleSource conventionSource = OpenGammaCompilationContext.getConventionBundleSource(context); // TODO [PLAT-5966] Remove
  final HistoricalTimeSeriesResolver timeSeriesResolver = OpenGammaCompilationContext.getHistoricalTimeSeriesResolver(context);
  final CurrencyPairs baseQuotePairs = OpenGammaCompilationContext.getCurrencyPairsSource(context).getCurrencyPairs(CurrencyPairs.DEFAULT_CURRENCY_PAIRS);
  final CashSecurityConverter cashConverter = new CashSecurityConverter(holidaySource, regionSource);
  final FRASecurityConverterDeprecated fraConverter = new FRASecurityConverterDeprecated(holidaySource, regionSource, conventionSource);
  final SwapSecurityConverterDeprecated swapConverter = new SwapSecurityConverterDeprecated(holidaySource, conventionSource, regionSource, false);
  final BondSecurityConverter bondConverter = new BondSecurityConverter(holidaySource, conventionSource, regionSource);
  final InterestRateFutureSecurityConverterDeprecated irFutureConverter = new InterestRateFutureSecurityConverterDeprecated(holidaySource, conventionSource, regionSource);
  final ForexSecurityConverter fxConverter = new ForexSecurityConverter(baseQuotePairs);
  return new Compiled(FinancialSecurityVisitorAdapter.<InstrumentDefinition<?>>builder().cashSecurityVisitor(cashConverter).fraSecurityVisitor(fraConverter)
      .swapSecurityVisitor(swapConverter).interestRateFutureSecurityVisitor(irFutureConverter).bondSecurityVisitor(bondConverter).fxForwardVisitor(fxConverter)
      .nonDeliverableFxForwardVisitor(fxConverter).create(), new FixedIncomeConverterDataProvider(conventionSource, securitySource, timeSeriesResolver));
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:19,代码来源:FixedCashFlowFunction.java

示例12: update

import org.threeten.bp.Instant; //导入依赖的package包/类
@Override
public ConventionDocument update(final ConventionDocument document) {
  ArgumentChecker.notNull(document, "document");
  ArgumentChecker.notNull(document.getUniqueId(), "document.uniqueId");
  ArgumentChecker.notNull(document.getConvention(), "document.convention");

  final UniqueId uniqueId = document.getUniqueId();
  final Instant now = Instant.now();
  final ConventionDocument storedDocument = _store.get(uniqueId.getObjectId());
  if (storedDocument == null) {
    throw new DataNotFoundException("Convention not found: " + uniqueId);
  }
  document.setVersionFromInstant(now);
  document.setVersionToInstant(null);
  document.setCorrectionFromInstant(now);
  document.setCorrectionToInstant(null);
  document.setUniqueId(uniqueId.withVersion(""));
  document.getValue().setUniqueId(uniqueId.withVersion(""));
  if (_store.replace(uniqueId.getObjectId(), storedDocument, document) == false) {
    throw new IllegalArgumentException("Concurrent modification");
  }
  _changeManager.entityChanged(ChangeType.CHANGED, document.getObjectId(), storedDocument.getVersionFromInstant(), document.getVersionToInstant(), now);
  return document;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:25,代码来源:InMemoryConventionMaster.java

示例13: compile

import org.threeten.bp.Instant; //导入依赖的package包/类
@Override
public CompiledFunctionDefinition compile(final FunctionCompilationContext context, final Instant atInstant) {
  return new BlackDiscountingCompiledFunction(getTargetToDefinitionConverter(context), getDefinitionToDerivativeConverter(context), true) {

    @Override
    protected Set<ComputedValue> getValues(final FunctionExecutionContext executionContext, final FunctionInputs inputs,
        final ComputationTarget target, final Set<ValueRequirement> desiredValues, final InstrumentDerivative derivative,
        final FXMatrix fxMatrix) {
      final BlackForexSmileProvider blackData = getBlackSurface(executionContext, inputs, target, fxMatrix);
      final double valueDelta = derivative.accept(CALCULATOR, blackData);
      final ValueRequirement desiredValue = Iterables.getOnlyElement(desiredValues);
      final ValueProperties properties = desiredValue.getConstraints().copy().get();
      final ValueSpecification spec = new ValueSpecification(VALUE_DELTA, target.toSpecification(), properties);
      return Collections.singleton(new ComputedValue(spec, valueDelta));
    }

  };
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:19,代码来源:BlackDiscountingValueDeltaFXOptionFunction.java

示例14: compile

import org.threeten.bp.Instant; //导入依赖的package包/类
@Override
public CompiledFunctionDefinition compile(final FunctionCompilationContext context, final Instant atInstant) {
  return new BlackDiscountingCompiledFunction(getTargetToDefinitionConverter(context), getDefinitionToDerivativeConverter(context), true) {

    @Override
    protected Set<ComputedValue> getValues(final FunctionExecutionContext executionContext, final FunctionInputs inputs,
        final ComputationTarget target, final Set<ValueRequirement> desiredValues, final InstrumentDerivative derivative,
        final FXMatrix fxMatrix) {
      final BlackForexSmileProvider blackData = getBlackSurface(executionContext, inputs, target, fxMatrix);
      final PresentValueForexBlackVolatilityQuoteSensitivityDataBundle vegas = derivative.accept(CALCULATOR, blackData);
      final ValueRequirement desiredValue = Iterables.getOnlyElement(desiredValues);
      final ValueProperties properties = desiredValue.getConstraints().copy().get();
      final ValueSpecification spec = new ValueSpecification(VEGA_QUOTE_MATRIX, target.toSpecification(), properties);
      return Collections.singleton(new ComputedValue(spec, VegaMatrixUtils.getVegaFXQuoteMatrix(vegas)));
    }

  };
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:19,代码来源:BlackDiscountingVegaQuoteMatrixFXOptionFunction.java

示例15: getResultsJson

import org.threeten.bp.Instant; //导入依赖的package包/类
public List<JsonObject> getResultsJson() {
    Map<Flow, List<Step>> resultsMap = getResultsMap();
    List<JsonObject> resultsJson = new ArrayList<>();
    for (Map.Entry entry : resultsMap.entrySet()) {

        List<Step> steps = (List<Step>) entry.getValue();
        Flow flow = (Flow) entry.getKey();
        Instant started = steps.get(0).getArrivedOn();

        if (steps.size() > 0) {
            resultsJson.add(JsonUtils.object(
                    "fields", JsonUtils.toJsonArray(m_fields.values()),
                    "steps", JsonUtils.toJsonArray(steps),
                    "flow", flow.getUuid(),
                    "contact", m_contact.getUuid(),
                    "started", ExpressionUtils.formatJsonDate(started),
                    "revision", flow.getMetadata().get("revision").getAsInt(),
                    "completed", m_completed,
                    "app_version", m_appVersion,
                    "submitted_by", m_username
            ));
        }
    }

    return resultsJson;
}
 
开发者ID:rapidpro,项目名称:surveyor,代码行数:27,代码来源:Submission.java


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