Package org.threeten.bp.temporal

Examples of org.threeten.bp.temporal.TemporalAdjuster


        _couponFrequency, _convention, _stubType);
  }

  private ZonedDateTime findSettlementDate(final ZonedDateTime startDate, final Convention convention) {

    final TemporalAdjuster adjuster = convention.getBusinessDayConvention().getTemporalAdjuster(convention.getWorkingDayCalendar());

    ZonedDateTime result = startDate;

    for (int i = 0, n = convention.getSettlementDays(); i < n; ++i) {
      result = result.plusDays(1).with(adjuster);
View Full Code Here


    _offset = offset;
  }

  @Override
  public Temporal adjustInto(Temporal temporal) {
    final TemporalAdjuster unadjustedDayInMonth = TemporalAdjusters.dayOfWeekInMonth(_week, _day);
    return temporal.with(unadjustedDayInMonth).plus(_offset, DAYS);
  }
View Full Code Here

  @Test
  public void testPrecedingDay() {
    final BusinessDayConvention convention = BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Preceding");
    assertNotNull(convention);
    final TemporalAdjuster adjuster = convention.getTemporalAdjuster(_calendar_UK);
    assertNotNull(adjuster);
    assertDate(adjuster, LocalDate.of(2009, 12, 31), LocalDate.of(2009, 12, 31));
    assertDate(adjuster, LocalDate.of(2010, 1, 1), LocalDate.of(2009, 12, 31)); // Fri 1 Jan -> Thu 31 Dec
    assertDate(adjuster, LocalDate.of(2010, 1, 2), LocalDate.of(2009, 12, 31));
    assertDate(adjuster, LocalDate.of(2010, 1, 3), LocalDate.of(2009, 12, 31));
View Full Code Here

  @Test
  public void testFollowingDay() {
    final BusinessDayConvention convention = BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following");
    assertNotNull(convention);
    final TemporalAdjuster adjuster = convention.getTemporalAdjuster(_calendar_UK);
    assertNotNull(adjuster);
    assertDate(adjuster, LocalDate.of(2009, 12, 31), LocalDate.of(2009, 12, 31));
    assertDate(adjuster, LocalDate.of(2010, 1, 1), LocalDate.of(2010, 1, 4)); // Fri 1 Jan -> Mon 4 Jan
    assertDate(adjuster, LocalDate.of(2010, 1, 2), LocalDate.of(2010, 1, 4));
    assertDate(adjuster, LocalDate.of(2010, 1, 3), LocalDate.of(2010, 1, 4));
View Full Code Here

  @Test
  public void testModifiedFollowingDay() {
    final BusinessDayConvention convention = BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Modified Following");
    assertNotNull(convention);
    final TemporalAdjuster adjuster = convention.getTemporalAdjuster(_calendar_UK);
    assertNotNull(adjuster);
    assertDate(adjuster, LocalDate.of(2009, 12, 31), LocalDate.of(2009, 12, 31));
    assertDate(adjuster, LocalDate.of(2010, 1, 1), LocalDate.of(2010, 1, 4)); // Fri 1 Jan -> Mon 4 Jan
    assertDate(adjuster, LocalDate.of(2010, 1, 2), LocalDate.of(2010, 1, 4));
    assertDate(adjuster, LocalDate.of(2010, 1, 3), LocalDate.of(2010, 1, 4));
View Full Code Here

  @Test
  public void testModifiedPrecedingDay() {
    final BusinessDayConvention convention = BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Modified Preceding");
    assertNotNull(convention);
    final TemporalAdjuster adjuster = convention.getTemporalAdjuster(_calendar_UK);
    assertNotNull(adjuster);
    assertDate(adjuster, LocalDate.of(2009, 12, 31), LocalDate.of(2009, 12, 31));
    assertDate(adjuster, LocalDate.of(2010, 1, 1), LocalDate.of(2010, 1, 4)); // Fri 1 Jan -> Mon 4 Jan
    assertDate(adjuster, LocalDate.of(2010, 1, 2), LocalDate.of(2010, 1, 4));
    assertDate(adjuster, LocalDate.of(2010, 1, 3), LocalDate.of(2010, 1, 4));
View Full Code Here

   * @param valDate The evaluation date
   * @return The expiry dates
   */
  public static TreeSet<LocalDate> getExpirySet(final LocalDate valDate) {
   
    final TemporalAdjuster thirdFriday = TemporalAdjusters.dayOfWeekInMonth(3, DayOfWeek.FRIDAY);
    TreeSet<LocalDate> expirySet = new TreeSet<LocalDate>();
   
    // Add the next six months' Expiries although they are not guaranteed to be traded
    final LocalDate thisMonthsExpiry = valDate.with(thirdFriday).plusDays(1);
    if (thisMonthsExpiry.isAfter(valDate)) {
View Full Code Here

  public TestResult runTestCase(final ISDATestGridRow testCase, final ISDACurve discountCurve) {

    final BusinessDayConvention businessDays = new FollowingBusinessDayConvention();
    final Calendar calendar = new MondayToFridayCalendar("TestCalendar");
    final Convention convention = new Convention(3, dayCount, businessDays, calendar, "");
    final TemporalAdjuster adjuster = businessDays.getTemporalAdjuster(calendar);

    final ZonedDateTime pricingDate = testCase.getTradeDate().atStartOfDay(ZoneOffset.UTC);
    final ZonedDateTime maturity = testCase.getMaturityDate().atStartOfDay(ZoneOffset.UTC);

    // Step-in date is always T+1 calendar
View Full Code Here

    return results;
  }

  protected ZonedDateTime findSettlementDate(final ZonedDateTime startDate, final Convention convention) {

    final TemporalAdjuster adjuster = convention.getBusinessDayConvention().getTemporalAdjuster(convention.getWorkingDayCalendar());

    ZonedDateTime result = startDate;

    for (int i = 0, n = convention.getSettlementDays(); i < n; ++i) {
      result = result.plusDays(1).with(adjuster);
View Full Code Here

    final ZonedDateTime nextIMMDate = ZonedDateTime.from(IMM_ADJUSTER.adjustInto(dateWithTradeAdjustment)).withDayOfMonth(TWENTIETH); // must be 20th
    return nextIMMDate.plus(tenor.getPeriod());
  }

  public static LocalDate getPreviousIMMDate(final LocalDate date) {
    final TemporalAdjuster adjuster = new TemporalAdjuster() {
      @Override
      public Temporal adjustInto(final Temporal temporal) {
        Temporal adjusted = temporal;
        do {
          adjusted = adjusted.minus(1, ChronoUnit.MONTHS);
View Full Code Here

TOP

Related Classes of org.threeten.bp.temporal.TemporalAdjuster

Copyright © 2018 www.massapicom. 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.