Examples of ZonedDateTime


Examples of org.threeten.bp.ZonedDateTime

        assertEquals(trans.hashCode(), otherTrans.hashCode());
    }

    public void test_Paris_getStandardOffset() {
        ZoneRules test = europeParis();
        ZonedDateTime zdt = createZDT(1840, 1, 1, ZoneOffset.UTC);
        while (zdt.getYear() < 2010) {
            Instant instant = zdt.toInstant();
            if (zdt.toLocalDate().isBefore(LocalDate.of(1911, 3, 11))) {
                assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHoursMinutesSeconds(0, 9, 21));
            } else if (zdt.toLocalDate().isBefore(LocalDate.of(1940, 6, 14))) {
                assertEquals(test.getStandardOffset(instant), OFFSET_ZERO);
            } else if (zdt.toLocalDate().isBefore(LocalDate.of(1944, 8, 25))) {
                assertEquals(test.getStandardOffset(instant), OFFSET_PONE);
            } else if (zdt.toLocalDate().isBefore(LocalDate.of(1945, 9, 16))) {
                assertEquals(test.getStandardOffset(instant), OFFSET_ZERO);
            } else {
                assertEquals(test.getStandardOffset(instant), OFFSET_PONE);
            }
            zdt = zdt.plusMonths(6);
        }
    }
View Full Code Here

Examples of org.threeten.bp.ZonedDateTime

        assertEquals(test.isFixedOffset(), false);
    }

    public void test_NewYork_preTimeZones() {
        ZoneRules test = americaNewYork();
        ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC);
        Instant instant = old.toInstant();
        ZoneOffset offset = ZoneOffset.of("-04:56:02");
        assertEquals(test.getOffset(instant), offset);
        checkOffset(test, old.toLocalDateTime(), offset, 1);
        assertEquals(test.getStandardOffset(instant), offset);
        assertEquals(test.getDaylightSavings(instant), Duration.ZERO);
        assertEquals(test.isDaylightSavings(instant), false);
    }
View Full Code Here

Examples of org.threeten.bp.ZonedDateTime

        assertEquals(trans.hashCode(), otherTrans.hashCode());
    }

    public void test_NewYork_getStandardOffset() {
        ZoneRules test = americaNewYork();
        ZonedDateTime dateTime = createZDT(1860, 1, 1, ZoneOffset.UTC);
        while (dateTime.getYear() < 2010) {
            Instant instant = dateTime.toInstant();
            if (dateTime.toLocalDate().isBefore(LocalDate.of(1883, 11, 18))) {
                assertEquals(test.getStandardOffset(instant), ZoneOffset.of("-04:56:02"));
            } else {
                assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHours(-5));
            }
            dateTime = dateTime.plusMonths(6);
        }
    }
View Full Code Here

Examples of org.threeten.bp.ZonedDateTime

    protected StringBuilder buf;

    @BeforeMethod
    public void setUp() {
        printEmptyContext = new DateTimePrintContext(EMPTY, Locale.ENGLISH, DecimalStyle.STANDARD);
        ZonedDateTime zdt = LocalDateTime.of(2011, 6, 30, 12, 30, 40, 0).atZone(ZoneId.of("Europe/Paris"));
        printContext = new DateTimePrintContext(zdt, Locale.ENGLISH, DecimalStyle.STANDARD);
        parseContext = new DateTimeParseContext(Locale.ENGLISH, DecimalStyle.STANDARD, IsoChronology.INSTANCE);
        buf = new StringBuilder();
    }
View Full Code Here

Examples of org.threeten.bp.ZonedDateTime

    //-----------------------------------------------------------------------
    // Test Serialization of ISO via chrono API
    //-----------------------------------------------------------------------
    @Test( dataProvider="calendars")
    public void test_ChronoZonedDateTimeSerialization(Chronology chrono) throws Exception {
        ZonedDateTime ref = LocalDate.of(2000, 1, 5).atTime(12, 1, 2, 3).atZone(ZoneId.of("GMT+01:23"));
        ChronoZonedDateTime<?> orginal = chrono.date(ref).atTime(ref.toLocalTime()).atZone(ref.getZone());
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(baos);
        out.writeObject(orginal);
        out.close();
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
View Full Code Here

Examples of org.threeten.bp.ZonedDateTime

  @Override
  public FRASecurity createSecurity(final OperationContext context, FRASecurityBean bean) {
    Currency currency = currencyBeanToCurrency(bean.getCurrency());
    ExternalId regionId = externalIdBeanToExternalId(bean.getRegion());
    ZonedDateTime startDate = zonedDateTimeBeanToDateTimeWithZone(bean.getStartDate());
    ZonedDateTime endDate = zonedDateTimeBeanToDateTimeWithZone(bean.getEndDate());
    double rate = bean.getRate();
    double amount = bean.getAmount();
    ExternalId underlyingId = externalIdBeanToExternalId(bean.getUnderlying());
    ZonedDateTime fixingDate = zonedDateTimeBeanToDateTimeWithZone(bean.getFixingDate());
    return new FRASecurity(currency, regionId, startDate, endDate, rate, amount, underlyingId, fixingDate);
  }
View Full Code Here

Examples of org.threeten.bp.ZonedDateTime

    s_logger.info(sb.toString());
    return securities;
  }

  private CapFloorSecurity makeCapFloor(final Random random, final Tenor tenor) {
    final ZonedDateTime maturityDate = TRADE_DATE.plus(tenor.getPeriod()).atStartOfDay(ZoneOffset.UTC);
    final boolean payer = random.nextBoolean();
    final boolean cap = random.nextBoolean();
    final double strike = getSwapRate(CURRENCY, TRADE_DATE, tenor) * (1 + ((0.5 - random.nextDouble()) / 30));
    final double notional = 1000000 * (1 + random.nextInt(50));
    final ExternalId underlyingId = TICKERS.get(tenor);
    if (underlyingId == null) {
      throw new OpenGammaRuntimeException("Could not get swap rate ticker for " + tenor);
    }
    final CapFloorSecurity security = new CapFloorSecurity(TRADE_DATE.atStartOfDay(ZoneOffset.UTC), maturityDate, notional, underlyingId, strike, PeriodFrequency.SEMI_ANNUAL,
        Currency.USD, ACT_360, payer, cap, false);
    security.setName("USD " + FORMAT.format(notional / 1000000) + (cap ? "MM cap " : "MM floor ") + "@ " + FORMAT.format(strike) +
        (payer ? "%, pay " : "%, receive ") + tenor.getPeriod().normalized().getYears() + "Y ISDA fixing" +
        " (" + TRADE_DATE.toString() + " - " + maturityDate.toLocalDate().toString() + ")");
    security.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    return security;
  }
View Full Code Here

Examples of org.threeten.bp.ZonedDateTime

    security.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    return security;
  }

  private SwapSecurity makeSwap(final Random random, final Tenor tenor) {
    final ZonedDateTime tradeDate = TRADE_DATE.atStartOfDay(ZoneOffset.UTC);
    final ZonedDateTime maturityDate = tradeDate.plus(tenor.getPeriod());
    final ExternalId iborReferenceRate = LIBOR_3M;
    final PeriodFrequency frequency = PeriodFrequency.QUARTERLY;
    final ExternalId cmsId = TICKERS.get(tenor);
    if (cmsId == null) {
      throw new OpenGammaRuntimeException("Could not get swap rate ticker for " + tenor);
    }
    final InterestRateNotional notional = new InterestRateNotional(Currency.USD, 1000000 * (1 + random.nextInt(50)));
    final FloatingInterestRateLeg iborLeg = new FloatingInterestRateLeg(ACT_360, frequency, REGION, FOLLOWING, notional, true,
        iborReferenceRate, FloatingRateType.IBOR);
    final FloatingInterestRateLeg cmsLeg = new FloatingInterestRateLeg(ACT_360, frequency, REGION, FOLLOWING, notional, true,
        cmsId, FloatingRateType.CMS);
    SwapSecurity security;
    boolean payIbor;
    if (random.nextBoolean()) {
      security = new SwapSecurity(tradeDate, tradeDate, maturityDate, COUNTERPARTY, iborLeg, cmsLeg);
      payIbor = true;
    } else {
      security = new SwapSecurity(tradeDate, tradeDate, maturityDate, COUNTERPARTY, cmsLeg, iborLeg);
      payIbor = false;
    }
    security.setName(CURRENCY.getCode() + " " + FORMAT.format(notional.getAmount() / 1000000) + "MM Swap, pay " +
        (payIbor ? frequency.getPeriod().getMonths() + "M Libor, receive " + tenor.getPeriod().getYears() + "Y ISDA fixing (" :
          tenor.getPeriod().getYears() + "Y ISDA fixing, receive " + frequency.getPeriod().getMonths() + "M Libor (") +
          tradeDate.toLocalDate().toString() + " - " + maturityDate.toLocalDate().toString() + ")");
    security.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    return security;
  }
View Full Code Here

Examples of org.threeten.bp.ZonedDateTime

    security.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    return security;
  }

  private CapFloorCMSSpreadSecurity makeCMSCapFloorSpread(final Random random, final Tenor payTenor, final Tenor receiveTenor, final Tenor maturity, final double strike) {
    final ZonedDateTime tradeDate = TRADE_DATE.atStartOfDay(ZoneOffset.UTC);
    final ZonedDateTime maturityDate = tradeDate.plus(maturity.getPeriod());
    final boolean payer = random.nextBoolean();
    final boolean cap = random.nextBoolean();
    final ExternalId payIdentifier = TICKERS.get(payTenor);
    if (payIdentifier == null) {
      throw new OpenGammaRuntimeException("Could not get swap rate ticker for " + payTenor);
    }
    final ExternalId receiveIdentifier = TICKERS.get(receiveTenor);
    if (receiveIdentifier == null) {
      throw new OpenGammaRuntimeException("Could not get swap rate ticker for " + receiveTenor);
    }
    final double notional = 1000000 * (1 + random.nextInt(50));
    final CapFloorCMSSpreadSecurity security = new CapFloorCMSSpreadSecurity(tradeDate, maturityDate, notional, payIdentifier, receiveIdentifier, strike,
        PeriodFrequency.ANNUAL, CURRENCY, ACT_360, payer, cap);
    security.setName(CURRENCY.getCode() + " " + FORMAT.format(notional / 1000000) + (cap ? "MM cap spread " : "MM floor spread ") + "@ " + FORMAT.format(strike) +
        "%, pay " + payTenor.getPeriod().normalized().getYears() + "Y ISDA fixing" + ", receive " +
        receiveTenor.getPeriod().normalized().getYears() + "Y ISDA fixing" +
        " (" + tradeDate.toLocalDate().toString() + " - " + maturityDate.toLocalDate().toString() + ")");
    security.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    return security;
  }
View Full Code Here

Examples of org.threeten.bp.ZonedDateTime

    return bean;
  }

  @Override
  public NonDeliverableFXForwardSecurity createSecurity(final OperationContext context, NonDeliverableFXForwardSecurityBean bean) {
    ZonedDateTime forwardDate = zonedDateTimeBeanToDateTimeWithZone(bean.getForwardDate());
    ExternalId region = externalIdBeanToExternalId(bean.getRegion());
    Currency payCurrency = currencyBeanToCurrency(bean.getPayCurrency());
    double payAmount = bean.getPayAmount();
    Currency receiveCurrency = currencyBeanToCurrency(bean.getReceiveCurrency());
    double receiveAmount = bean.getReceiveAmount();
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.