Examples of ZoneId


Examples of org.threeten.bp.ZoneId

                int endPos = OffsetIdPrinterParser.INSTANCE_ID.parse(newContext, text, position);
                if (endPos < 0) {
                    return endPos;
                }
                int offset = (int) newContext.getParsed(OFFSET_SECONDS).longValue();
                ZoneId zone = ZoneOffset.ofTotalSeconds(offset);
                context.setParsed(zone);
                return endPos;
            } else if (length >= position + 2) {
                char nextNextChar = text.charAt(position + 1);
                if (context.charEquals(nextChar, 'U') &&
                                context.charEquals(nextNextChar, 'T')) {
                    if (length >= position + 3 &&
                                    context.charEquals(text.charAt(position + 2), 'C')) {
                        return parsePrefixedOffset(context, text, position, position + 3);
                    }
                    return parsePrefixedOffset(context, text, position, position + 2);
                } else if (context.charEquals(nextChar, 'G') &&
                        length >= position + 3 &&
                        context.charEquals(nextNextChar, 'M') &&
                        context.charEquals(text.charAt(position + 2), 'T')) {
                    return parsePrefixedOffset(context, text, position, position + 3);
                }
            }

            // prepare parse tree
            Set<String> regionIds = ZoneRulesProvider.getAvailableZoneIds();
            final int regionIdsSize = regionIds.size();
            Entry<Integer, SubstringTree> cached = cachedSubstringTree;
            if (cached == null || cached.getKey() != regionIdsSize) {
                synchronized (this) {
                    cached = cachedSubstringTree;
                    if (cached == null || cached.getKey() != regionIdsSize) {
                        cachedSubstringTree = cached = new SimpleImmutableEntry<Integer, SubstringTree>(regionIdsSize, prepareParser(regionIds));
                    }
                }
            }
            SubstringTree tree = cached.getValue();

            // parse
            String parsedZoneId = null;
            while (tree != null) {
                int nodeLength = tree.length;
                if (position + nodeLength > length) {
                    break;
                }
                parsedZoneId = text.subSequence(position, position + nodeLength).toString();
                tree = tree.get(parsedZoneId, context.isCaseSensitive());
            }
            ZoneId zone = convertToZone(regionIds, parsedZoneId, context.isCaseSensitive());
            if (zone == null) {
                if (context.charEquals(nextChar, 'Z')) {
                    context.setParsed(ZoneOffset.UTC);
                    return position + 1;
                }
View Full Code Here

Examples of org.threeten.bp.ZoneId

     * @throws DateTimeException if unable to create the date-time
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public ChronoZonedDateTime<?> zonedDateTime(TemporalAccessor temporal) {
        try {
            ZoneId zone = ZoneId.from(temporal);
            try {
                Instant instant = Instant.from(temporal);
                return zonedDateTime(instant, zone);

            } catch (DateTimeException ex1) {
View Full Code Here

Examples of org.threeten.bp.ZoneId

    }

    static ChronoZonedDateTime<?> readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
        ChronoLocalDateTime<?> dateTime = (ChronoLocalDateTime<?>) in.readObject();
        ZoneOffset offset = (ZoneOffset) in.readObject();
        ZoneId zone = (ZoneId) in.readObject();
        return dateTime.atZone(offset).withZoneSameLocal(zone);
        // TODO: ZDT uses ofLenient()
    }
View Full Code Here

Examples of org.threeten.bp.ZoneId

    final int spotLag = indexConvention.getSettlementDays();
    final IborIndex iborIndex = new IborIndex(currency, indexTenor, spotLag, dayCount, businessDayConvention, eom, indexConvention.getName());
    final ExchangeTradedInstrumentExpiryCalculator expiryCalculator = ExchangeTradedInstrumentExpiryCalculatorFactory.getCalculator(expiryCalculatorName);
    final ZonedDateTime startDate = _valuationTime.plus(rateFuture.getStartTenor().getPeriod());
    final LocalTime time = startDate.toLocalTime();
    final ZoneId timeZone = startDate.getZone();
    final ZonedDateTime expiryDate = ZonedDateTime.of(expiryCalculator.getExpiryDate(rateFuture.getFutureNumber(), startDate.toLocalDate(), regionCalendar), time, timeZone);
    final InterestRateFutureSecurityDefinition securityDefinition = new InterestRateFutureSecurityDefinition(expiryDate, iborIndex, 1, paymentAccrualFactor, "", fixingCalendar);
    final InterestRateFutureTransactionDefinition transactionDefinition = new InterestRateFutureTransactionDefinition(securityDefinition, _valuationTime, price, 1);
    //return transactionDefinition;
View Full Code Here

Examples of org.threeten.bp.ZoneId

    final double paymentAccrualFactor = 1 / 12.;
    final Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, indexConvention.getRegionCalendar());
    final ExchangeTradedInstrumentExpiryCalculator expiryCalculator = ExchangeTradedInstrumentExpiryCalculatorFactory.getCalculator(expiryCalculatorName);
    final ZonedDateTime startDate = _valuationTime.plus(rateFuture.getStartTenor().getPeriod());
    final LocalTime time = startDate.toLocalTime();
    final ZoneId timeZone = startDate.getZone();
    final ZonedDateTime expiryDate = ZonedDateTime.of(expiryCalculator.getExpiryDate(rateFuture.getFutureNumber(), startDate.toLocalDate(), calendar), time, timeZone);
    final FederalFundsFutureSecurityDefinition securityDefinition = FederalFundsFutureSecurityDefinition.from(expiryDate,
                                                                                                              index, 1, paymentAccrualFactor, "", calendar);
    final FederalFundsFutureTransactionDefinition transactionDefinition = new FederalFundsFutureTransactionDefinition(securityDefinition, 1, _valuationTime, price);
    //return transactionDefinition;
View Full Code Here

Examples of org.threeten.bp.ZoneId

    user.setPasswordHash("TESTHASH");
    user.setName("Test Name");
    user.setEmailAddress("test@test.com");
    user.setExternalIdBundle(BUNDLE);
    user.setEntitlements(Sets.newHashSet("A", "B"));
    ZoneId zone = user.getTimeZone();
    UserDocument doc = new UserDocument(user);
    UserDocument test = _usrMaster.add(doc);
   
    UniqueId uniqueId = test.getUniqueId();
    assertNotNull(uniqueId);
View Full Code Here

Examples of org.threeten.bp.ZoneId

    final InterestRateFutureSecurityDefinition securityDefinition = _securityConverter.visitInterestRateFutureSecurity((InterestRateFutureSecurity) trade.getSecurity());
    // REVIEW: Setting this quantity to one so that we don't double-count the number of trades when the position scaling takes place
    final int quantity = trade.getQuantity().intValue();
    ZonedDateTime tradeDate;
    if (trade.getTradeTime() != null) {
      final ZoneId zone = trade.getTradeTime().getOffset();
      tradeDate = trade.getTradeDate().atTime(trade.getTradeTime().toLocalTime()).atZone(zone);
    } else {
      tradeDate = trade.getTradeDate().atTime(LocalTime.NOON).atZone(ZoneOffset.UTC);
    }
    final double tradePrice = trade.getPremium() == null ? 0 : trade.getPremium(); //TODO remove the default value and throw an exception
View Full Code Here

Examples of org.threeten.bp.ZoneId

    // different ones for each leg?
    final BusinessDayConvention businessDayConvention = fixedLegConvention.getBusinessDayConvention();
    final boolean endOfMonth = fixedLegConvention.isIsEOM();
    final Currency currency = priceIndexConvention.getCurrency();
    final Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, priceIndexConvention.getRegion());
    final ZoneId zone = _valuationTime.getZone(); //TODO time zone set to midnight UTC
    final ZonedDateTime settlementDate = ScheduleCalculator.getAdjustedDate(_valuationTime, settlementDays, calendar).toLocalDate().atStartOfDay(zone);
    final ZonedDateTime paymentDate = ScheduleCalculator.getAdjustedDate(settlementDate, tenor, businessDayConvention, calendar, endOfMonth).toLocalDate().atStartOfDay(zone);
    final CouponFixedCompoundingDefinition fixedCoupon = CouponFixedCompoundingDefinition.from(currency, settlementDate, paymentDate, notional, tenor.getYears(),
        rate);
    final HistoricalTimeSeries ts = _timeSeries.get(MarketDataRequirementNames.MARKET_VALUE, priceIndexConvention.getPriceIndexId());
View Full Code Here

Examples of org.threeten.bp.ZoneId

    if (regionId == null) {
      throw new OpenGammaRuntimeException("Could not find region for " + security.getIssuerDomicile());
    }
    final Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, regionId);
    final Currency currency = security.getCurrency();
    final ZoneId zone = security.getInterestAccrualDate().getZone();
    final ZonedDateTime firstAccrualDate = ZonedDateTime.of(security.getInterestAccrualDate().toLocalDate().atStartOfDay(), zone);
    final ZonedDateTime maturityDate = ZonedDateTime.of(security.getLastTradeDate().getExpiry().toLocalDate().atStartOfDay(), zone);
    final double rate = security.getCouponRate() / 100;
    final DayCount dayCount = security.getDayCount();
    final BusinessDayConvention businessDay = BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following");
View Full Code Here

Examples of org.threeten.bp.ZoneId

    final String expiryCalculatorName = futureConvention.getExpiryConvention().getValue();
    final ZonedDateTime startDate = _valuationTime.plus(swapFuture.getStartTenor().getPeriod());
    final Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, futureConvention.getExchangeCalendar());
    final ExchangeTradedInstrumentExpiryCalculator expiryCalculator = ExchangeTradedInstrumentExpiryCalculatorFactory.getCalculator(expiryCalculatorName);
    final LocalTime time = startDate.toLocalTime();
    final ZoneId timeZone = startDate.getZone();
    final double notional = 1.0;
    final int spotLagSwap = fixedLegConvention.getSettlementDays();
    final ZonedDateTime lastTradeDate = ZonedDateTime.of(expiryCalculator.getExpiryDate(swapFuture.getFutureNumber(), startDate.toLocalDate(), calendar), time, timeZone);
    final ZonedDateTime deliveryDate = ScheduleCalculator.getAdjustedDate(lastTradeDate, spotLagSwap, calendar);
    final Convention underlyingConvention = _conventionSource.getConvention(iborLegConvention.getIborIndexConvention());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.