本文整理汇总了Java中org.threeten.bp.ZoneOffset类的典型用法代码示例。如果您正苦于以下问题:Java ZoneOffset类的具体用法?Java ZoneOffset怎么用?Java ZoneOffset使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ZoneOffset类属于org.threeten.bp包,在下文中一共展示了ZoneOffset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addRecord
import org.threeten.bp.ZoneOffset; //导入依赖的package包/类
public void addRecord()
{
if (recordnumber<neednumber)
{
recordnumber++;
have_record_all++;
}
if (recordnumber == neednumber){
//list add days from today to begin
long diff = 0;
LocalDateTime begindatetime=getBeginLocalDate();
LocalDateTime begindate=LocalDateTime.of(begindatetime.getYear(),begindatetime.getMonth(),
begindatetime.getDayOfMonth(),0,0);
diff = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)-begindate.toEpochSecond(ZoneOffset.UTC);
int diff_int = (int)diff;
Integer day = diff_int/60/60/24;
Log.e("Ken: dif for habits", String.valueOf(diff)+" "+diff+" "+day);
record.add(day);
}
}
示例2: fetchLibrariesFromApiAndSaveThem
import org.threeten.bp.ZoneOffset; //导入依赖的package包/类
@Test
public void fetchLibrariesFromApiAndSaveThem() {
OffsetDateTime lastUpdated = OffsetDateTime.of(2016, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
when(libraryService.lastUpdated()).thenReturn(Observable.just(lastUpdated));
List<Library> newLibraries = Collections.singletonList(MockLibrary.TEST);
when(disclosureApi.allLibraries(any(), anyInt(), anyInt()))
.thenReturn(Observable.just(newLibraries))
.thenReturn(Observable.just(new ArrayList<>()));
TestSubscriber<List<Library>> testSubscriber = new TestSubscriber<>();
syncLibraries.run()
.toBlocking()
.subscribe(testSubscriber);
verify(disclosureApi).allLibraries(lastUpdated, 1, 50);
verify(libraryService).insertOrUpdate(newLibraries);
testSubscriber.assertReceivedOnNext(Collections.singletonList(newLibraries));
testSubscriber.assertNoErrors();
testSubscriber.assertCompleted();
}
示例3: callOnErrorIfApiReturnsAnError
import org.threeten.bp.ZoneOffset; //导入依赖的package包/类
@Test
public void callOnErrorIfApiReturnsAnError() {
OffsetDateTime lastUpdated = OffsetDateTime.of(2016, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
when(libraryService.lastUpdated()).thenReturn(Observable.just(lastUpdated));
Throwable apiError = new Throwable();
when(disclosureApi.allLibraries(any(), anyInt(), anyInt())).thenReturn(
Observable.error(apiError));
TestSubscriber<List<Library>> testSubscriber = new TestSubscriber<>();
syncLibraries.run()
.toBlocking()
.subscribe(testSubscriber);
testSubscriber.assertError(apiError);
}
示例4: newInfo
import org.threeten.bp.ZoneOffset; //导入依赖的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;
}
示例5: addSessionReminder
import org.threeten.bp.ZoneOffset; //导入依赖的package包/类
public void addSessionReminder(@NonNull Session session) {
if (!isEnabled()) {
Timber.d("SessionsReminder is not enable, skip adding session");
return;
}
PendingIntent intent = createSessionReminderIntent(session);
LocalDateTime now = LocalDateTime.now();
LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
if (!sessionStartTime.isAfter(now)) {
Timber.w("Do not set reminder for passed session");
return;
}
Timber.d("Setting reminder on %s", sessionStartTime);
App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
}
示例6: createFunctionExecutionContext
import org.threeten.bp.ZoneOffset; //导入依赖的package包/类
private FunctionExecutionContext createFunctionExecutionContext(final LocalDate valuationTime) {
final FunctionExecutionContext context = new FunctionExecutionContext();
context.setValuationTime(valuationTime.atTime(LocalTime.NOON).toInstant(ZoneOffset.UTC));
context.setValuationClock(DateUtils.fixedClockUTC(context.getValuationTime()));
context.setComputationTargetResolver(
new DefaultComputationTargetResolver(context.getSecuritySource()).atVersionCorrection(VersionCorrection.LATEST));
OpenGammaExecutionContext.setHolidaySource(context, getHolidaySource());
OpenGammaExecutionContext.setRegionSource(context, getRegionSource());
OpenGammaExecutionContext.setConventionBundleSource(context, getConventionBundleSource());
OpenGammaExecutionContext.setConventionSource(context, getConventionSource());
OpenGammaExecutionContext.setSecuritySource(context, new MasterSecuritySource(getSecurityMaster()));
OpenGammaExecutionContext.setHistoricalTimeSeriesSource(context, getHistoricalSource());
OpenGammaExecutionContext.setConfigSource(context, getConfigSource());
OpenGammaExecutionContext.setLegalEntitySource(context, getLegalEntitySource());
return context;
}
示例7: toDerivativeNoFixingAfterTradeDate
import org.threeten.bp.ZoneOffset; //导入依赖的package包/类
@Test
/**
* Tests the toDerivative method before the security first fixing date - after trade date.
*/
public void toDerivativeNoFixingAfterTradeDate() {
final ZonedDateTime referenceDate = ScheduleCalculator.getAdjustedDate(TRADE_DATE, 1, NYC);
final ZonedDateTime[] closingDate = new ZonedDateTime[] {TRADE_DATE.minusDays(2), TRADE_DATE.minusDays(1), TRADE_DATE};
final double[] closingPrice = new double[] {0.99895, 0.99905, 0.99915};
final ZonedDateTimeDoubleTimeSeries closingTS = ImmutableZonedDateTimeDoubleTimeSeries.of(closingDate, closingPrice, ZoneOffset.UTC);
final ZonedDateTime[] fixingDate = new ZonedDateTime[] {TRADE_DATE.minusDays(2), TRADE_DATE.minusDays(1), TRADE_DATE};
final double[] fixingRate = new double[] {0.0010, 0.0011, 0.0009};
final ZonedDateTimeDoubleTimeSeries fixingTS = ImmutableZonedDateTimeDoubleTimeSeries.of(fixingDate, fixingRate, ZoneOffset.UTC);
final ZonedDateTimeDoubleTimeSeries[] data = new ZonedDateTimeDoubleTimeSeries[] {fixingTS, closingTS};
final FederalFundsFutureSecurity securityConverted = FUTURE_SECURITY_DEFINITION.toDerivative(referenceDate, fixingTS);
final FederalFundsFutureTransaction transactionExpected = new FederalFundsFutureTransaction(securityConverted, QUANTITY, closingPrice[2]);
final FederalFundsFutureTransaction transactionConverted = FUTURE_TRANSACTION_DEFINITION.toDerivative(referenceDate, data);
assertEquals("Fed fund future transaction definition: toDerivative", transactionExpected, transactionConverted);
}
示例8: createSecurity
import org.threeten.bp.ZoneOffset; //导入依赖的package包/类
@Override
protected ManageableSecurity createSecurity() {
FutureOptionSecurityDefinition defn = getSecurityDefinition();
ExternalId underlyingId = defn.getUnderlyingId().toExternalId();
Expiry expiry = new Expiry(defn.getFutureExpiry().atDay(1).atStartOfDay(ZoneOffset.UTC), ExpiryAccuracy.MONTH_YEAR);
String exchange = defn.getExchange();
Currency currency = defn.getCurrency();
int pointValue = defn.getPointValue();
boolean isMargined = defn.isIsMargined();
double strike = defn.getStrike().doubleValue();
OptionType optionType = defn.getOptionType();
ExerciseType exerciseType = defn.getExerciseType().convert();
switch (defn.getListedFutureOptionType()) {
case EQUITY_INDEX_FUTURE_OPTION:
return new EquityIndexFutureOptionSecurity(exchange, expiry, exerciseType, underlyingId, pointValue,
isMargined, currency, strike, optionType);
case EQUITY_DIVIDEND_FUTURE_OPTION:
return new EquityIndexDividendFutureOptionSecurity(exchange, expiry, exerciseType, underlyingId, pointValue,
isMargined, currency, strike, optionType);
default:
// The xml validation should prevent this from happening
throw new PortfolioParsingException("Unrecognised listed option type: " + defn.getListedFutureOptionType());
}
}
示例9: historySelected
import org.threeten.bp.ZoneOffset; //导入依赖的package包/类
private void historySelected() {
s_logger.warn("history selected");
MarketDataSpecificationComponent outer = MarketDataSpecificationComponent.this;
@SuppressWarnings("unchecked")
JComboBox<String> source = _dataSourceCombo;
String item = (String) source.getSelectedItem();
if (item != null) {
MarketDataSpecification marketDataSpec;
if (_latestRadio.isSelected()) {
marketDataSpec = new LatestHistoricalMarketDataSpecification(item);
validSpecification(marketDataSpec);
return;
} else {
Date datePickerDate = outer._datePicker.getDate();
if (item != null && item.length() > 0 && datePickerDate != null) {
LocalDate localDate = Instant.ofEpochMilli(datePickerDate.getTime()).atZone(ZoneOffset.UTC).toLocalDate();
marketDataSpec = new FixedHistoricalMarketDataSpecification(item, localDate);
validSpecification(marketDataSpec);
return;
}
}
}
invalidSpecification();
}
示例10: visitEquityTotalReturnSwapSecurity
import org.threeten.bp.ZoneOffset; //导入依赖的package包/类
@Override
public EquityTotalReturnSwapDefinition visitEquityTotalReturnSwapSecurity(final EquityTotalReturnSwapSecurity security) {
ArgumentChecker.notNull(security, "security");
final FinancialSecurity underlying = (FinancialSecurity) _securitySource.getSingle(security.getAssetId().toBundle()); //TODO ignoring version
if (underlying instanceof BondSecurity) {
throw new OpenGammaRuntimeException("Underlying for equity TRS was not an equity");
}
final FloatingInterestRateSwapLeg fundingLeg = security.getFundingLeg();
final boolean isPayer = fundingLeg.getPayReceiveType() == PayReceiveType.PAY ? true : false;
final LocalDate startDate = security.getEffectiveDate();
final LocalDate endDate = security.getMaturityDate();
final NotionalExchange notionalExchange = NotionalExchange.NO_EXCHANGE;
final AnnuityDefinition<? extends PaymentDefinition> annuityDefinition = AnnuityUtils.buildFloatingAnnuityDefinition(_conventionSource, _holidaySource, _securitySource, isPayer,
startDate, endDate, notionalExchange, fundingLeg);
final EquitySecurity equity = (EquitySecurity) underlying;
final LegalEntity legalEntity = getLegalEntityForEquity(equity);
final EquityDefinition equityDefinition = new EquityDefinition(legalEntity, equity.getCurrency(), security.getNumberOfShares());
final ZonedDateTime startDateTime = startDate.atTime(LocalTime.MIN).atZone(ZoneOffset.UTC);
final ZonedDateTime endDateTime = endDate.atTime(LocalTime.MIN).atZone(ZoneOffset.UTC);
return new EquityTotalReturnSwapDefinition(startDateTime, endDateTime, annuityDefinition, equityDefinition, security.getNotionalAmount(),
security.getNotionalCurrency(), security.getDividendPercentage() / 100.);
}
示例11: convert
import org.threeten.bp.ZoneOffset; //导入依赖的package包/类
public InstrumentDefinitionWithData<?, Double> convert(Trade trade) {
ArgumentChecker.notNull(trade, "trade");
final Security security = trade.getSecurity();
if (security instanceof DeliverableSwapFutureSecurity) {
final SwapFuturesPriceDeliverableSecurityDefinition securityDefinition = (SwapFuturesPriceDeliverableSecurityDefinition) ((DeliverableSwapFutureSecurity) security).accept(_securityConverter);
Double tradePrice = trade.getPremium(); // TODO: [PLAT-1958] The trade price is stored in the trade premium.
if (tradePrice == null) {
throw new OpenGammaRuntimeException("Trade premium should not be null.");
}
final LocalDate tradeDate = trade.getTradeDate();
if (tradeDate == null) {
throw new OpenGammaRuntimeException("Trade date should not be null");
}
final OffsetTime tradeTime = trade.getTradeTime();
if (tradeTime == null) {
throw new OpenGammaRuntimeException("Trade time should not be null");
}
final ZonedDateTime tradeDateTime = tradeDate.atTime(tradeTime).atZoneSameInstant(ZoneOffset.UTC);
final int quantity = trade.getQuantity().intValue();
return new SwapFuturesPriceDeliverableTransactionDefinition(securityDefinition, quantity, tradeDateTime, tradePrice);
}
throw new IllegalArgumentException("Can only handle DeliverableSwapFutureSecurity");
}
示例12: getTimeSeriesRequirements
import org.threeten.bp.ZoneOffset; //导入依赖的package包/类
@Override
public Set<ValueRequirement> getTimeSeriesRequirements(final ZeroCouponInflationSwapSecurity security) {
Validate.notNull(security, "security");
final SwapLeg payLeg = security.getPayLeg();
final SwapLeg receiveLeg = security.getReceiveLeg();
final ZonedDateTime swapStartDate = security.getEffectiveDate();
final ZonedDateTime swapStartLocalDate = swapStartDate.toLocalDate().atStartOfDay(ZoneOffset.UTC);
final ValueRequirement payLegTS = getIndexTimeSeriesRequirement(payLeg, swapStartLocalDate);
final ValueRequirement receiveLegTS = getIndexTimeSeriesRequirement(receiveLeg, swapStartLocalDate);
final Set<ValueRequirement> requirements = new HashSet<>();
if (payLegTS != null) {
requirements.add(payLegTS);
}
if (receiveLegTS != null) {
requirements.add(receiveLegTS);
}
return requirements;
}
示例13: test_intersectionFirstValue_selectFirst
import org.threeten.bp.ZoneOffset; //导入依赖的package包/类
@Test
public void test_intersectionFirstValue_selectFirst() {
final ZonedDateTimeDoubleTimeSeries dts = createStandardTimeSeries();
final ZonedDateTimeDoubleTimeSeries dts2 = createStandardTimeSeries2();
final ZonedDateTimeDoubleTimeSeries dts3 = ImmutableZonedDateTimeDoubleTimeSeries.builder(ZoneOffset.UTC)
.putAll(dts2).put(dts2.getEarliestTime(), -1.0).build();
final ZonedDateTimeDoubleTimeSeries result1 = dts.intersectionFirstValue(dts3);
assertEquals(3, result1.size());
assertEquals(Double.valueOf(4.0), result1.getValueAtIndex(0));
assertEquals(Double.valueOf(5.0), result1.getValueAtIndex(1));
assertEquals(Double.valueOf(6.0), result1.getValueAtIndex(2));
assertEquals(dts.getTimeAtIndex(3), result1.getTimeAtIndex(0));
assertEquals(dts.getTimeAtIndex(4), result1.getTimeAtIndex(1));
assertEquals(dts.getTimeAtIndex(5), result1.getTimeAtIndex(2));
final ZonedDateTimeDoubleTimeSeries result2 = dts3.intersectionFirstValue(dts);
assertEquals(3, result2.size());
assertEquals(Double.valueOf(-1.0), result2.getValueAtIndex(0));
assertEquals(Double.valueOf(5.0), result2.getValueAtIndex(1));
assertEquals(Double.valueOf(6.0), result2.getValueAtIndex(2));
assertEquals(dts.getTimeAtIndex(3), result2.getTimeAtIndex(0));
assertEquals(dts.getTimeAtIndex(4), result2.getTimeAtIndex(1));
assertEquals(dts.getTimeAtIndex(5), result2.getTimeAtIndex(2));
}
示例14: convert
import org.threeten.bp.ZoneOffset; //导入依赖的package包/类
public InstrumentDefinitionWithData<?, Double> convert(Trade trade) {
ArgumentChecker.notNull(trade, "trade");
final Security security = trade.getSecurity();
if (security instanceof InterestRateFutureSecurity) {
final InterestRateFutureSecurityDefinition securityDefinition = (InterestRateFutureSecurityDefinition) ((InterestRateFutureSecurity) security).accept(_securityConverter);
Double tradePrice = trade.getPremium(); // TODO: [PLAT-1958] The trade price is stored in the trade premium.
if (tradePrice == null) {
throw new OpenGammaRuntimeException("Trade premium should not be null.");
}
final LocalDate tradeDate = trade.getTradeDate();
if (tradeDate == null) {
throw new OpenGammaRuntimeException("Trade date should not be null");
}
final OffsetTime tradeTime = trade.getTradeTime();
if (tradeTime == null) {
throw new OpenGammaRuntimeException("Trade time should not be null");
}
final ZonedDateTime tradeDateTime = tradeDate.atTime(tradeTime).atZoneSameInstant(ZoneOffset.UTC);
final int quantity = trade.getQuantity().intValue();
return new InterestRateFutureTransactionDefinition(securityDefinition, quantity, tradeDateTime, tradePrice);
}
throw new IllegalArgumentException("Can only handle InterestRateFutureSecurity");
}
示例15: createInterestRateFutureTrade
import org.threeten.bp.ZoneOffset; //导入依赖的package包/类
private InterestRateFutureTrade createInterestRateFutureTrade(InterestRateFutureSecurity security,
SimpleCounterparty counterparty,
boolean pass) {
BigDecimal tradeQuantity = BigDecimal.valueOf(10);
LocalDate tradeDate = LocalDate.of(2000, 1, 1);
OffsetTime tradeTime = OffsetTime.of(LocalTime.of(0, 0), ZoneOffset.UTC);
SimpleTrade trade = new SimpleTrade(security, tradeQuantity, counterparty, tradeDate, tradeTime);
trade.setPremium(0.0);
trade.setPremiumCurrency(security.getCurrency());
if (pass) {
trade.addAttribute("TEST", "PASS");
} else {
trade.addAttribute("TEST", "FAIL");
}
return new InterestRateFutureTrade(trade);
}