本文整理汇总了Java中org.threeten.bp.LocalTime类的典型用法代码示例。如果您正苦于以下问题:Java LocalTime类的具体用法?Java LocalTime怎么用?Java LocalTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LocalTime类属于org.threeten.bp包,在下文中一共展示了LocalTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNextTuesdayMorningTimestamp
import org.threeten.bp.LocalTime; //导入依赖的package包/类
public static long getNextTuesdayMorningTimestamp(boolean allowSameDay) {
ZonedDateTime nextTuesday;
if (allowSameDay) {
// If today is Tuesday (before 08:10), we'll get a timestamp in the future. Great !
// If today is Tuesday (after 08:10), we'll get a timestamp in the past, AlarmManager is garanteed to trigger immediatly. Neat.
// If today is not Tuesday, everything is fine, we get next tuesday epoch
nextTuesday = getNowTime().with(TemporalAdjusters.nextOrSame(DayOfWeek.TUESDAY));
} else {
// We are tuesday, get next week timestamp with TemporalAdjusters.next instead of TemporalAdjusters.nextOrSame
// If we are not tuesday, it doesn't "loop over" and give a timestamp in > 7 days
nextTuesday = getNowTime().with(TemporalAdjusters.next(DayOfWeek.TUESDAY));
}
nextTuesday = nextTuesday.with(LocalTime.of(8, 10)); // TODO VOLKO USER CAN SET THIS IN OPTION
return nextTuesday.toInstant().toEpochMilli();
}
示例2: newInfo
import org.threeten.bp.LocalTime; //导入依赖的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;
}
示例3: RxBindingExampleViewModel
import org.threeten.bp.LocalTime; //导入依赖的package包/类
@Inject
public RxBindingExampleViewModel() {
final long intervalMs = 10;
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("mm:ss:SS");
timeStream = Observable
.interval(intervalMs, TimeUnit.MILLISECONDS)
.onBackpressureDrop()
.map(beats -> Duration.ofMillis(intervalMs * beats))
.map(duration -> formatter.format(LocalTime.MIDNIGHT.plus(duration)));
calculateSubject = PublishSubject.create();
highLoadStream = calculateSubject
.observeOn(Schedulers.computation())
.scan((sum, value) -> ++sum)
.map(iteration -> {
// Simulate high processing load
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {}
return iteration;
});
}
示例4: createDialog
import org.threeten.bp.LocalTime; //导入依赖的package包/类
/**
* Creates a {@link TimePickerDialog} instance.
*
* @param context to retrieve the time format (12 or 24 hour)
* @param localTime the initial localTime
* @param listener to listen for a localTime selection
* @param clock to retrieve the calendar from
* @return a new instance of {@link TimePickerDialog}
*/
@NonNull
public static TimePickerDialog createDialog(@NonNull Context context, @Nullable LocalTime localTime,
@Nullable Consumer<LocalTime> listener, @NonNull Clock clock) {
TimePickerDialog.OnTimeSetListener dialogCallBack = (view, hourOfDay, minute, second) -> {
LocalTime time = LocalTime.of(hourOfDay, minute, second);
Optional.ofNullable(listener)
.ifPresent(theListener -> theListener.accept(time));
};
localTime = Optional.ofNullable(localTime)
.orElse(LocalTime.now(clock));
TimePickerDialog timePickerDialog = TimePickerDialog.newInstance(
dialogCallBack,
localTime.getHour(),
localTime.getMinute(),
localTime.getSecond(),
DateFormat.is24HourFormat(context)
);
timePickerDialog.dismissOnPause(true);
return timePickerDialog;
}
示例5: setUp
import org.threeten.bp.LocalTime; //导入依赖的package包/类
@Before
public void setUp() {
random = new Random();
mainActivityPresenter.attachView(viewMock);
when(userControllerMock.getUserFromCache())
.thenReturn(Single.just(userMock));
when(settingsMock.getNotificationSettings())
.thenReturn(notificationSettingsMock);
when(notificationSettingsMock.isEnabled()).thenReturn(true);
when(settingsControllerMock.getSettings())
.thenReturn(Single.just(settingsMock));
when(settingsControllerMock.getNotificationSettings())
.thenReturn(Single.just(notificationSettingsMock));
when(logoutControllerMock.performLogout()).thenReturn(Completable.complete());
when(onboardingController.isOnboardingPassed()).thenReturn(Single.just(true));
when(userControllerMock.isGuestModeEnabled()).thenReturn(Single.just(false));
when(errorControllerMock.getThrowableMessage(any(Throwable.class)))
.thenCallRealMethod();
when(dateTimeFormatUtilMock.getFormattedTime(anyInt(), anyInt()))
.thenAnswer(invocation -> {
Object[] args = invocation.getArguments();
return LocalTime.of((Integer) args[0],
(Integer) args[1]).format(TIME_FORMATTER);
});
}
示例6: createVanillaFixedVsLibor3mTrade
import org.threeten.bp.LocalTime; //导入依赖的package包/类
private static InterestRateSwapTrade createVanillaFixedVsLibor3mTrade() {
Counterparty counterparty = new SimpleCounterparty(ExternalId.of(Counterparty.DEFAULT_SCHEME, "COUNTERPARTY"));
BigDecimal tradeQuantity = BigDecimal.valueOf(1);
LocalDate tradeDate = LocalDate.of(2014, 1, 22);
OffsetTime tradeTime = OffsetTime.of(LocalTime.of(0, 0), ZoneOffset.UTC);
SimpleTrade trade = new SimpleTrade(createVanillaFixedVsLibor3mSwap(), tradeQuantity, counterparty, tradeDate, tradeTime);
trade.setPremium(0.0);
trade.setPremiumDate(tradeDate);
trade.setPremiumCurrency(Currency.USD);
/* A specific InterestRateSwapTrade object here is used to 'wrap' the underlying generic SimpleTrade */
return new InterestRateSwapTrade(trade);
}
示例7: testGetPositionWithTrades
import org.threeten.bp.LocalTime; //导入依赖的package包/类
@Test
public void testGetPositionWithTrades() throws Exception {
final ManageableTrade trade = new ManageableTrade(BigDecimal.valueOf(50), SEC_ID, LocalDate.parse("2011-12-07"), OffsetTime.of(LocalTime.of(15, 4), ZONE_OFFSET), COUNTER_PARTY);
trade.setPremium(10.0);
trade.setPremiumCurrency(Currency.USD);
trade.setPremiumDate(LocalDate.parse("2011-12-08"));
trade.setPremiumTime(OffsetTime.of(LocalTime.of(15, 4), ZONE_OFFSET));
final ManageablePosition manageablePosition = new ManageablePosition(trade.getQuantity(), SEC_ID);
manageablePosition.addTrade(trade);
final PositionDocument addedPos = _positionMaster.add(new PositionDocument(manageablePosition));
final WebPositionResource positionResource = _webPositionsResource.findPosition(addedPos.getUniqueId().toString());
final String json = positionResource.getJSON();
assertNotNull(json);
assertJSONObjectEquals(loadJson("com/opengamma/web/position/position.txt"), new JSONObject(json));
}
示例8: setWidgetUpdateAlarm
import org.threeten.bp.LocalTime; //导入依赖的package包/类
/**
* Sets widget update alarm.
*
* @param context the context
*/
public static void setWidgetUpdateAlarm(Context context) {
if (getAppWidgetCount(context) > 0) {
Timber.d("Setting WidgetUpdateAlarm...");
LocalDateTime dateTime = LocalDateTime.of(LocalDate.now().plusDays(1), LocalTime.MIDNIGHT);
AlarmManager manager = getAlarmManager(context);
manager.setInexactRepeating(
AlarmManager.RTC_WAKEUP,
convertLocalDateTimeToMillis(dateTime),
TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS),
IntentUtils.getWidgetUpdatePendingIntent(context)
);
setBootReceiverEnabled(context, true);
}
}
示例9: getTradingCloseTime
import org.threeten.bp.LocalTime; //导入依赖的package包/类
/**
* THIS IS NOT READY FOR PRIME TIME YET
* @param exchangeSource a source of exchanges, we assume it provides ManageableExchanges
* @param isoMic an external id with the ISO MIC code of the exchange
* @param today the date today (to allow for changes in opening hours over time)
* @param defaultTime a fallback time to use if a close time could not be established, if set to null, will return null in time field.
* @return a pair of values, the end of trading period and the time zone or null if no exchange with that code was found. Time can be null if defaultTime==null.
*/
public static Pair<LocalTime, ZoneId> getTradingCloseTime(ExchangeSource exchangeSource, ExternalId isoMic, LocalDate today, LocalTime defaultTime) {
ManageableExchange exchange = (ManageableExchange) exchangeSource.getSingle(isoMic);
if (exchange != null) {
for (ManageableExchangeDetail detail : exchange.getDetail()) {
if (detail.getPhaseName().equals("Trading") &&
(detail.getCalendarStart() == null || detail.getCalendarStart().equals(today) || detail.getCalendarStart().isBefore(today)) &&
(detail.getCalendarEnd() == null || detail.getCalendarEnd().equals(today) || detail.getCalendarEnd().isAfter(today))) {
LocalTime endTime = detail.getPhaseEnd();
if (endTime != null) {
return Pairs.of(endTime, exchange.getTimeZone());
}
}
}
s_logger.warn("Couldn't find exchagne close time for {}, defaulting to supplied default", isoMic);
return Pairs.of(defaultTime, exchange.getTimeZone());
} else {
return null;
}
}
示例10: createFunctionExecutionContext
import org.threeten.bp.LocalTime; //导入依赖的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;
}
示例11: getFederalFundsFuture
import org.threeten.bp.LocalTime; //导入依赖的package包/类
/**
* Creates a Federal fund future from a rate future node.
* @param rateFuture The rate future node
* @param futureConvention The future convention
* @param price The price
* @return The Fed fund future
*/
private InstrumentDefinition<?> getFederalFundsFuture(RateFutureNode rateFuture, FederalFundsFutureConvention futureConvention,
Double price) {
String expiryCalculatorName = futureConvention.getExpiryConvention().getValue();
OvernightIndex index =
SecurityLink.resolvable(futureConvention.getIndexConvention(), OvernightIndex.class).resolve();
OvernightIndexConvention indexConvention =
ConventionLink.resolvable(index.getConventionId(), OvernightIndexConvention.class).resolve();
IndexON indexON = ConverterUtils.indexON(index.getName(), indexConvention);
double paymentAccrualFactor = 1 / 12.;
Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, indexConvention.getRegionCalendar());
ExchangeTradedInstrumentExpiryCalculator expiryCalculator =
ExchangeTradedInstrumentExpiryCalculatorFactory.getCalculator(expiryCalculatorName);
ZonedDateTime startDate = _valuationTime.plus(rateFuture.getStartTenor().getPeriod());
LocalTime time = startDate.toLocalTime();
ZoneId timeZone = startDate.getZone();
ZonedDateTime expiryDate = ZonedDateTime.of(
expiryCalculator.getExpiryDate(rateFuture.getFutureNumber(), startDate.toLocalDate(), calendar), time, timeZone);
FederalFundsFutureSecurityDefinition securityDefinition =
FederalFundsFutureSecurityDefinition.from(expiryDate, indexON, 1, paymentAccrualFactor, "", calendar);
return new FederalFundsFutureTransactionDefinition(securityDefinition, 1, _valuationTime, price);
}
示例12: compile
import org.threeten.bp.LocalTime; //导入依赖的package包/类
@Override
public CompiledFunctionDefinition compile(final FunctionCompilationContext context, final Instant atInstant) {
final ZonedDateTime atZDT = ZonedDateTime.ofInstant(atInstant, ZoneOffset.UTC);
//TODO work out a way to use dependency graph to get curve information for this config
final CurveConstructionConfiguration curveConstructionConfiguration = _curveConstructionConfigurationSource.getCurveConstructionConfiguration(_configurationName);
if (curveConstructionConfiguration == null) {
throw new OpenGammaRuntimeException("Could not get curve construction configuration called " + _configurationName);
}
final ConventionSource conventionSource = OpenGammaCompilationContext.getConventionSource(context);
final SecuritySource securitySource = OpenGammaCompilationContext.getSecuritySource(context);
final ConfigSource configSource = OpenGammaCompilationContext.getConfigSource(context);
try {
final CurveNodeVisitor<Set<Currency>> visitor = new CurveNodeCurrencyVisitor(conventionSource, securitySource, configSource);
final Set<Currency> currencies = CurveUtils.getCurrencies(curveConstructionConfiguration, _curveDefinitionSource, _curveConstructionConfigurationSource, visitor);
final ValueProperties properties = createValueProperties().with(CURVE_CONSTRUCTION_CONFIG, _configurationName).get();
final ValueSpecification spec = new ValueSpecification(ValueRequirementNames.FX_MATRIX, ComputationTargetSpecification.NULL, properties);
return new MyCompiledFunction(atZDT.with(LocalTime.MIDNIGHT), atZDT.plusDays(1).with(LocalTime.MIDNIGHT).minusNanos(1000000), spec, currencies);
} catch (final Throwable e) {
s_logger.error("{}: problem in CurveConstructionConfiguration called {}", e.getMessage(), _configurationName);
s_logger.error("Full stack trace", e);
throw new OpenGammaRuntimeException(e.getMessage() + ": problem in CurveConstructionConfiguration called " + _configurationName);
}
}
示例13: visitEquityTotalReturnSwapSecurity
import org.threeten.bp.LocalTime; //导入依赖的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.);
}
示例14: updatePositionWithNoTrades
import org.threeten.bp.LocalTime; //导入依赖的package包/类
/**
* update a position that doesn't have any trades. position's quantity should match trade and trade should be added
*/
@Test
public void updatePositionWithNoTrades() {
ManageablePosition position = new ManageablePosition(BigDecimal.valueOf(42), APPLE_SECURITY.getExternalIdBundle());
ManageablePosition savedPosition = _positionMaster.add(new PositionDocument(position)).getPosition();
assertEquals(BigDecimal.valueOf(42), savedPosition.getQuantity());
_tradeBuilder.updatePosition(createTradeData("AAPL US Equity", null), savedPosition.getUniqueId());
ManageablePosition updatedPosition = _positionMaster.get(savedPosition.getUniqueId().getObjectId(),
VersionCorrection.LATEST).getPosition();
assertEquals(BigDecimal.valueOf(30), updatedPosition.getQuantity());
assertEquals(1, updatedPosition.getTrades().size());
ManageableTrade trade = updatedPosition.getTrades().get(0);
assertEquals(LocalDate.of(2012, 12, 21), trade.getTradeDate());
assertEquals(OffsetTime.of(LocalTime.of(14, 25), ZoneOffset.UTC), trade.getTradeTime());
assertEquals(APPLE_BUNDLE, trade.getSecurityLink().getExternalId());
assertEquals(1234d, trade.getPremium());
assertEquals(Currency.USD, trade.getPremiumCurrency());
assertEquals(LocalDate.of(2012, 12, 22), trade.getPremiumDate());
assertEquals(OffsetTime.of(LocalTime.of(13, 30), ZoneOffset.UTC), trade.getPremiumTime());
assertEquals(BigDecimal.valueOf(30), trade.getQuantity());
assertEquals(ExternalId.of(AbstractTradeBuilder.CPTY_SCHEME, "cptyName"), trade.getCounterpartyExternalId());
assertTrue(trade.getAttributes().isEmpty());
}
示例15: IborIndexConvention
import org.threeten.bp.LocalTime; //导入依赖的package包/类
/**
* Creates an instance.
*
* @param name the convention name, not null
* @param externalIdBundle the external identifiers for this convention, not null
* @param dayCount the day-count, not null
* @param businessDayConvention the business-day convention, not null
* @param settlementDays the settlement days
* @param isEOM true if dates follow the end-of-month rule
* @param currency the currency, not null
* @param fixingTime the fixing time, not null
* @param fixingTimeZone the fixing time zone, not null
* @param fixingCalendar the fixing calendar, not null
* @param regionCalendar the region calendar, not null
* @param fixingPage the fixing page name, not null
*/
public IborIndexConvention(
final String name, final ExternalIdBundle externalIdBundle, final DayCount dayCount,
final BusinessDayConvention businessDayConvention, final int settlementDays, final boolean isEOM,
final Currency currency, final LocalTime fixingTime, final String fixingTimeZone,
final ExternalId fixingCalendar, final ExternalId regionCalendar, final String fixingPage) {
super(name, externalIdBundle);
setDayCount(dayCount);
setBusinessDayConvention(businessDayConvention);
setSettlementDays(settlementDays);
setIsEOM(isEOM);
setCurrency(currency);
setFixingTime(fixingTime);
setFixingTimeZone(fixingTimeZone);
setFixingCalendar(fixingCalendar);
setRegionCalendar(regionCalendar);
setFixingPage(fixingPage);
}