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


Java ZonedDateTime类代码示例

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


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

示例1: Scheduler

import org.threeten.bp.ZonedDateTime; //导入依赖的package包/类
public Scheduler(){
    poller = Executors.newScheduledThreadPool(10);
    poller.scheduleAtFixedRate(() -> {
        ExecutableUnit unit = waiting.poll();
        if(unit!=null){
            Optional<ZonedDateTime> next = unit.getTrigger().nextExecution();
            if(next.isPresent() && isNextSecond(next.get())){
                //TODO verify date of last execution is not current
                //TODO group executing add/remove into a method
                //TODO create ExecutionInstance and manage status there
                if(!executingIDs.contains(unit.getJob().getId())){
                    executing.add(unit);
                    executor.execute(unit.getJob());
                    executingIDs.add(unit.getJob().getId());
                }
            }else{
                if(next.isPresent()){
                    waiting.add(unit);
                }
            }
        }
    }, 0, 10, TimeUnit.MILLISECONDS);
}
 
开发者ID:jmrozanec,项目名称:cron-utils-scheduler,代码行数:24,代码来源:Scheduler.java

示例2: getNextTuesdayMorningTimestamp

import org.threeten.bp.ZonedDateTime; //导入依赖的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();
}
 
开发者ID:NinoDLC,项目名称:CineReminDay,代码行数:19,代码来源:CRDTimeManager.java

示例3: fetchHistoryOfChannel

import org.threeten.bp.ZonedDateTime; //导入依赖的package包/类
@Override
public List<SlackMessagePosted> fetchHistoryOfChannel(String channelId, LocalDate day, int numberOfMessages) {
    Map<String, String> params = new HashMap<>();
    params.put("channel", channelId);
    if (day != null) {
        ZonedDateTime start = ZonedDateTime.of(day.atStartOfDay(), ZoneId.of("UTC"));
        ZonedDateTime end = ZonedDateTime.of(day.atStartOfDay().plusDays(1).minus(1, ChronoUnit.MILLIS), ZoneId.of("UTC"));
        params.put("oldest", convertDateToSlackTimestamp(start));
        params.put("latest", convertDateToSlackTimestamp(end));
    }
    if (numberOfMessages > -1) {
        params.put("count", String.valueOf(numberOfMessages));
    } else {
        params.put("count", String.valueOf(DEFAULT_HISTORY_FETCH_SIZE));
    }
    SlackChannel channel =session.findChannelById(channelId);
    switch (channel.getType()) {
        case INSTANT_MESSAGING:
            return fetchHistoryOfChannel(params,FETCH_IM_HISTORY_COMMAND);
        case PRIVATE_GROUP:
            return fetchHistoryOfChannel(params,FETCH_GROUP_HISTORY_COMMAND);
        default:
            return fetchHistoryOfChannel(params,FETCH_CHANNEL_HISTORY_COMMAND);
    }
}
 
开发者ID:riversun,项目名称:slacklet,代码行数:26,代码来源:ChannelHistoryModuleImpl.java

示例4: newInfo

import org.threeten.bp.ZonedDateTime; //导入依赖的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

示例5: ShotDB

import org.threeten.bp.ZonedDateTime; //导入依赖的package包/类
@Generated(hash = 1054056122)
public ShotDB(Long id, String title, ZonedDateTime creationDate, String projectUrl, int likesCount,
              int bucketCount, int commentsCount, String description, boolean isGif, String hiDpiImageUrl,
              String normalImageUrl, String thumbnailUrl, boolean isBucketed, boolean isLiked, Long userId,
              Long teamId) {
    this.id = id;
    this.title = title;
    this.creationDate = creationDate;
    this.projectUrl = projectUrl;
    this.likesCount = likesCount;
    this.bucketCount = bucketCount;
    this.commentsCount = commentsCount;
    this.description = description;
    this.isGif = isGif;
    this.hiDpiImageUrl = hiDpiImageUrl;
    this.normalImageUrl = normalImageUrl;
    this.thumbnailUrl = thumbnailUrl;
    this.isBucketed = isBucketed;
    this.isLiked = isLiked;
    this.userId = userId;
    this.teamId = teamId;
}
 
开发者ID:netguru,项目名称:inbbbox-android,代码行数:23,代码来源:ShotDB.java

示例6: setUp

import org.threeten.bp.ZonedDateTime; //导入依赖的package包/类
@Before
public void setUp() {
    when(bucketsControllerMock.isShotBucketed(anyLong())).thenReturn(Single.just(true));
    when(bucketsControllerMock.removeShotFromBucket(anyLong(), eq(shotMock))).
            thenReturn(Completable.complete());
    when(bucketsControllerMock.addShotToBucket(anyLong(), any()))
            .thenReturn(Completable.complete());

    when(viewMock.getShotInitialData()).thenReturn(shotMock);

    when(rxBusMock.getEvents(any())).thenReturn(Observable.empty());

    when(shotMock.id()).thenReturn(EXAMPLE_ID);
    when(shotMock.author()).thenReturn(User.create(Statics.USER_ENTITY));
    when(shotMock.creationDate()).thenReturn(ZonedDateTime.now());

    when(errorControllerMock.getThrowableMessage(any(Throwable.class))).thenCallRealMethod();

    shotDetailsPresenter.attachView(viewMock);
    shotDetailsPresenter.retrieveInitialData();
}
 
开发者ID:netguru,项目名称:inbbbox-android,代码行数:22,代码来源:ShotDetailsPresenterTest.java

示例7: getFollowingMock

import org.threeten.bp.ZonedDateTime; //导入依赖的package包/类
private static List<ShotEntity> getFollowingMock(int count, String label) {
    List<ShotEntity> result = new ArrayList<>();

    for (int i = 0; i < count; i++) {
        Image image = Image.builder().build();
        result.add(
                ShotEntity.builder()
                        .id(i)
                        .title(label + i)
                        .image(image)
                        .createdAt(ZonedDateTime.now())
                        .animated(false)
                        .animated(false)
                        .likesCount(2)
                        .bucketsCount(3)
                        .createdAt(ZonedDateTime.now())
                        .commentsCount(2)
                        .build());
    }
    return result;
}
 
开发者ID:netguru,项目名称:inbbbox-android,代码行数:22,代码来源:Statics.java

示例8: getShotsEntityList

import org.threeten.bp.ZonedDateTime; //导入依赖的package包/类
public static List<ShotEntity> getShotsEntityList(int count) {
    List<ShotEntity> result = new ArrayList<>();

    for (int i = 0; i < count; i++) {
        Image image = Image.builder().build();
        result.add(
                ShotEntity.builder()
                        .id(i)
                        .title("test: " + i)
                        .image(image)
                        .createdAt(ZonedDateTime.now())
                        .animated(false)
                        .likesCount(2)
                        .bucketsCount(3)
                        .createdAt(ZonedDateTime.now())
                        .commentsCount(2)
                        .build());
    }
    return result;
}
 
开发者ID:netguru,项目名称:inbbbox-android,代码行数:21,代码来源:Statics.java

示例9: setUp

import org.threeten.bp.ZonedDateTime; //导入依赖的package包/类
@Before
public void setUp() {
    LikedShotEntity entity = LikedShotEntity.builder()
            .id(EXAMPLE_ID)
            .shot(shotEntityMock)
            .createdAt("2016-12-12")
            .build();
    expectedItems = new ArrayList<>();
    expectedItems.add(entity);
    when(shotEntityMock.image()).thenReturn(imageMock);
    when(shotEntityMock.createdAt()).thenReturn(ZonedDateTime.now());
    when(likesApiMock.getLikedShots(PAGE_NUMBER, PAGE_COUNT))
            .thenReturn(Observable.just(expectedItems));
    when(shotMock.id()).thenReturn(EXAMPLE_ID);
    when(likesApiMock.isShotLiked(anyLong())).thenReturn(Completable.complete());
    when(likesApiMock.likeShot(anyLong())).thenReturn(Completable.complete());
    when(likesApiMock.unLikeShot(anyLong())).thenReturn(Completable.complete());
}
 
开发者ID:netguru,项目名称:inbbbox-android,代码行数:19,代码来源:LikeShotControllerApiTest.java

示例10: fetchHistoryOfChannel

import org.threeten.bp.ZonedDateTime; //导入依赖的package包/类
@Override
public List<SlackMessagePosted> fetchHistoryOfChannel(String channelId, LocalDate day, int numberOfMessages) {
    Map<String, String> params = new HashMap<>();
    params.put("channel", channelId);
    if (day != null) {
        ZonedDateTime start = ZonedDateTime.of(day.atStartOfDay(), ZoneId.of("UTC"));
        ZonedDateTime end = ZonedDateTime.of(day.atStartOfDay().plusDays(1).minus(1, ChronoUnit.MILLIS), ZoneId.of("UTC"));
        params.put("oldest", convertDateToSlackTimestamp(start));
        params.put("latest", convertDateToSlackTimestamp(end));
    }
    if (numberOfMessages > -1) {
        params.put("count", String.valueOf(numberOfMessages));
    } else {
        params.put("count", String.valueOf(1000));
    }
    return fetchHistoryOfChannel(params);
}
 
开发者ID:JujaLabs,项目名称:microservices,代码行数:18,代码来源:ChannelHistoryModuleImpl.java

示例11: createCapFloorSecurity

import org.threeten.bp.ZonedDateTime; //导入依赖的package包/类
private CapFloorSecurity createCapFloorSecurity() {
  final ZonedDateTime startDate = ZonedDateTime.now().minusMonths(24);
  final ZonedDateTime maturityDate = ZonedDateTime.now().plusMonths(60);
  final double notional = 1e6;
  final ExternalId underlyingIdentifier = ExternalId.of(ExternalSchemes.RIC, "USDSFIX10Y=");
  final double strike = 0.01;
  final Frequency frequency = frequency();
  final Currency currency = currency();
  final DayCount dayCount = dayCount();
  final boolean payer = bool();
  final boolean cap = bool();
  final boolean ibor = bool();
  final CapFloorSecurity security = new CapFloorSecurity(startDate, maturityDate, notional, underlyingIdentifier, strike, frequency, currency, dayCount, payer, cap, ibor);
  store(security);
  return security;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:17,代码来源:BloombergReferencePortfolioMaker.java

示例12: toDerivative

import org.threeten.bp.ZonedDateTime; //导入依赖的package包/类
@Override
public BondFuture toDerivative(final ZonedDateTime valDate, final Double referencePrice) {
  ArgumentChecker.notNull(valDate, "valDate must always be provided to form a Derivative from a Definition");
  ArgumentChecker.isTrue(!valDate.isAfter(getDeliveryLastDate()), "Valuation date is after last delivery date");

  final double lastTradingTime = TimeCalculator.getTimeBetween(valDate, getTradingLastDate());
  final double firstNoticeTime = TimeCalculator.getTimeBetween(valDate, getNoticeFirstDate());
  final double lastNoticeTime = TimeCalculator.getTimeBetween(valDate, getNoticeLastDate());
  final double firstDeliveryTime = TimeCalculator.getTimeBetween(valDate, getDeliveryFirstDate());
  final double lastDeliveryTime = TimeCalculator.getTimeBetween(valDate, getDeliveryLastDate());

  final BondFixedSecurity[] basket = new BondFixedSecurity[_deliveryBasket.length];
  for (int loopbasket = 0; loopbasket < _deliveryBasket.length; loopbasket++) {
    basket[loopbasket] = _deliveryBasket[loopbasket].toDerivative(valDate, _deliveryLastDate);
  }

  final BondFuture futureDeriv = new BondFuture(lastTradingTime, firstNoticeTime, lastNoticeTime, firstDeliveryTime, lastDeliveryTime, _notional, basket,
      _conversionFactor, referencePrice);
  return futureDeriv;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:21,代码来源:BondFutureDefinition.java

示例13: EquityFutureDefinition

import org.threeten.bp.ZonedDateTime; //导入依赖的package包/类
/**
 * Basic setup for an Equity Future. TODO resolve conventions; complete param set
 * @param expiryDate The date-time at which the reference rate is fixed and the future is cash settled
 * @param settlementDate The date on which exchange is made, whether physical asset or cash equivalent
 * @param strikePrice The reference price at which the future will be settled
 * @param currency The reporting currency of the future
 * @param unitValue The currency value that the price of one contract will move by when the asset's price moves by one point
 */
public EquityFutureDefinition(
    final ZonedDateTime expiryDate,
    final ZonedDateTime settlementDate,
    final double strikePrice,
    final Currency currency,
    final double unitValue) {
  Validate.notNull(expiryDate, "expiry");
  Validate.notNull(settlementDate, "settlement date");
  Validate.notNull(currency, "currency");
  _expiryDate = expiryDate;
  _settlementDate = settlementDate;
  _strikePrice = strikePrice;
  _currency = currency;
  _unitAmount = unitValue;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:24,代码来源:EquityFutureDefinition.java

示例14: pv01CurveParametersBeforeFirstFixing

import org.threeten.bp.ZonedDateTime; //导入依赖的package包/类
@Test
public void pv01CurveParametersBeforeFirstFixing() {
  final ZonedDateTime referenceDate = DateUtils.getUTCDate(2012, 5, 14);
  final SwapFixedCoupon<Coupon> swap = SWAP_FIXED_IBOR_DEFINITION.toDerivative(referenceDate);
  final ReferenceAmount<Pair<String, Currency>> pv01Computed = swap.accept(PV01CPC, MULTICURVES);
  final ReferenceAmount<Pair<String, Currency>> pv01Expected = new ReferenceAmount<>();
  final MultipleCurrencyParameterSensitivity pvps = PSPVC.calculateSensitivity(swap, MULTICURVES, MULTICURVES.getAllNames());
  for (final Pair<String, Currency> nameCcy : pvps.getAllNamesCurrency()) {
    double total = 0.0;
    final double[] array = pvps.getSensitivity(nameCcy).getData();
    for (final double element : array) {
      total += element;
    }
    total *= BP1;
    pv01Expected.add(nameCcy, total);
  }
  assertEquals("PV01CurveParametersCalculator: fixed-coupon swap", pv01Expected, pv01Computed);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:19,代码来源:SwapCalculatorTest.java

示例15: toDerivativesNoData

import org.threeten.bp.ZonedDateTime; //导入依赖的package包/类
@Test
public void toDerivativesNoData() {
  final ZonedDateTime pricingDate = DateUtils.getUTCDate(2011, 7, 29);
  final Coupon zeroCouponConverted = YoY_CAP_DEFINITION.toDerivative(pricingDate);
  //lastKnownFixingTime could be negatif so we don't use the dayfraction
  final double lastKnownFixingTime = TimeCalculator.getTimeBetween(pricingDate, LAST_KNOWN_FIXING_DATE);
  final double paymentTime = ACT_ACT.getDayCountFraction(pricingDate, PAYMENT_DATE);
  final double referenceStartTime0 = ACT_ACT.getDayCountFraction(pricingDate, REFERENCE_START_DATE[0]);
  final double referenceEndTime0 = ACT_ACT.getDayCountFraction(pricingDate, REFERENCE_END_DATE[0]);
  final double referenceStartTime1 = ACT_ACT.getDayCountFraction(pricingDate, REFERENCE_START_DATE[1]);
  final double referenceEndTime1 = ACT_ACT.getDayCountFraction(pricingDate, REFERENCE_END_DATE[1]);
  final double naturalPaymentStartPaymentTime = ACT_ACT.getDayCountFraction(pricingDate, ACCRUAL_START_DATE);
  final double naturalPaymentEndPaymentTime = ACT_ACT.getDayCountFraction(pricingDate, ACCRUAL_END_DATE);
  final double[] referenceStartTime = new double[2];
  final double[] referenceEndTime = new double[2];
  referenceStartTime[0] = referenceStartTime0;
  referenceStartTime[1] = referenceStartTime1;
  referenceEndTime[0] = referenceEndTime0;
  referenceEndTime[1] = referenceEndTime1;
  final CapFloorInflationYearOnYearInterpolation zeroCoupon = new CapFloorInflationYearOnYearInterpolation(CUR, paymentTime, 1.0, NOTIONAL, PRICE_INDEX, lastKnownFixingTime,
      referenceStartTime, naturalPaymentStartPaymentTime, referenceEndTime, naturalPaymentEndPaymentTime, WEIGHT_START, WEIGHT_END, STRIKE, IS_CAP);
  assertEquals("Inflation zero-coupon: toDerivative", zeroCouponConverted, zeroCoupon);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:24,代码来源:CapFloorInflationYearOnYearInterpolationDefinitionTest.java


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