Package org.threeten.bp

Examples of org.threeten.bp.Month


        } else {
            throw new IllegalArgumentException("Unknown line");
        }

        int year = Integer.parseInt(st.nextToken());
        Month month = parseMonth(st.nextToken());
        int dayOfMonth = Integer.parseInt(st.nextToken());
        LocalDate leapDate = LocalDate.of(year, month, dayOfMonth);
        String timeOfLeapSecond = st.nextToken();

        byte adjustmentByte = 0;
View Full Code Here


     * @return the created object, not null
     * @throws IOException if an error occurs
     */
    static ZoneOffsetTransitionRule readExternal(DataInput in) throws IOException {
        int data = in.readInt();
        Month month = Month.of(data >>> 28);
        int dom = ((data & (63 << 22)) >>> 22) - 32;
        int dowByte = (data & (7 << 19)) >>> 19;
        DayOfWeek dow = dowByte == 0 ? null : DayOfWeek.of(dowByte);
        int timeByte = (data & (31 << 14)) >>> 14;
        TimeDefinition defn = TimeDefinition.values()[(data & (3 << 12)) >>> 12];
View Full Code Here

      }
      throw new IllegalArgumentException("Start date and end date were the same but their day of month was not the same as that required");
    }
    final List<LocalDate> dates = new ArrayList<>();
    int year = endDate.getYear();
    Month month = startDate.getMonth();
    LocalDate date = startDate.withMonth(month.getValue()).withDayOfMonth(_dayOfMonth);
    if (date.isBefore(startDate)) {
      month = month.plus(1);
      date = date.withMonth(month.getValue());
    }
    year = date.getYear();
    while (!date.isAfter(endDate)) {
      dates.add(date);
      month = month.plus(1);
      if (month == Month.JANUARY) {
        year++;
      }
      date = LocalDate.of(year, month.getValue(), _dayOfMonth);
    }
    return dates.toArray(EMPTY_LOCAL_DATE_ARRAY);
  }
View Full Code Here

      }
      throw new IllegalArgumentException("Start date and end date were the same but their day of month was not the same as that required");
    }
    final List<ZonedDateTime> dates = new ArrayList<>();
    int year = endDate.getYear();
    Month month = startDate.getMonth();
    ZonedDateTime date = startDate.withMonth(month.getValue()).withDayOfMonth(_dayOfMonth);
    if (date.isBefore(startDate)) {
      month = month.plus(1);
      date = date.withMonth(month.getValue());
    }
    year = date.getYear();
    while (!date.isAfter(endDate)) {
      dates.add(date);
      month = month.plus(1);
      if (month == Month.JANUARY) {
        year++;
      }
      date = date.with(LocalDate.of(year, month.getValue(), _dayOfMonth));
    }
    return dates.toArray(EMPTY_ZONED_DATE_TIME_ARRAY);
  }
View Full Code Here

    // set day to first possible - used in getExpiryDate()
    return LocalDate.of(expiryDate.getYear(), expiryDate.getMonth(), 14);
  }

  private LocalDate getNextExpiryMonth(final LocalDate dtCurrent) {
    final Month mthCurrent = dtCurrent.getMonth();
    final int idx = Arrays.binarySearch(COMMODITY_FUTURE_EXPIRY_MONTHS, mthCurrent);
    if (Math.abs(idx) >= (COMMODITY_FUTURE_EXPIRY_MONTHS.length - 1)) {
      return LocalDate.of(dtCurrent.getYear() + 1, Month.JANUARY, dtCurrent.getDayOfMonth());
    } else if (idx >= 0) {
      return dtCurrent.with(COMMODITY_FUTURE_EXPIRY_MONTHS[idx + 1]);
View Full Code Here

        if ((thisYear % 10) > year) {
          year = ((thisYear / 10) * 10) + 10 + year;
        } else if ((thisYear % 10) == year) {
          // This code assumes that the code is for this year, so constructs a trial date using the year and month and adjusts it forward to the expiry
          // note we're not taking into account exchange closing time here.
          final Month month = s_monthCode.inverse().get(monthCode);
          if (month == null) {
            throw new OpenGammaRuntimeException("Invalid month code " + monthCode);
          }
          LocalDate nextExpiryIfThisYear = LocalDate.of((((thisYear / 10) * 10) + year), month, 1).with(s_monthlyExpiryAdjuster);
          ZonedDateTime nextExpiryDateTimeIfThisYear = nextExpiryIfThisYear.atTime(futureExpiryTime).atZoneSimilarLocal(futureExpiryTimeZone);
View Full Code Here

    }
    return expiryDate.with(LAST_DAY_ADJUSTER);
  }

  private LocalDate getNextExpiryMonth(final LocalDate dtCurrent) {
    Month mthCurrent = dtCurrent.getMonth();
    int idx = Arrays.binarySearch(CATTLE_FUTURE_EXPIRY_MONTHS, mthCurrent);
    if (Math.abs(idx) >= (CATTLE_FUTURE_EXPIRY_MONTHS.length - 1)) {
      return LocalDate.of(dtCurrent.getYear() + 1, Month.FEBRUARY, dtCurrent.getDayOfMonth());
    } else if (idx >= 0) {
      return dtCurrent.with(CATTLE_FUTURE_EXPIRY_MONTHS[idx + 1]);
View Full Code Here

    }
    return expiryDate;
  }

  private LocalDate getNextExpiryMonth(final Month[] validMonths, final LocalDate dtCurrent) {
    Month mthCurrent = dtCurrent.getMonth();
    int idx = Arrays.binarySearch(validMonths, mthCurrent);
    if (Math.abs(idx) >= (validMonths.length - 1)) {
      return LocalDate.of(dtCurrent.getYear() + 1, validMonths[0], dtCurrent.getDayOfMonth());
    } else if (idx >= 0) {
      return dtCurrent.with(validMonths[idx + 1]);
View Full Code Here

    }
    return expiryDate;
  }

  private LocalDate getNextExpiryMonth(final LocalDate dtCurrent) {
    Month mthCurrent = dtCurrent.getMonth();
    int idx = Arrays.binarySearch(CATTLE_OPTION_EXPIRY_MONTHS, mthCurrent);
    if (idx >= (CATTLE_OPTION_EXPIRY_MONTHS.length - 1)) {
      return LocalDate.of(dtCurrent.getYear() + 1, CATTLE_OPTION_EXPIRY_MONTHS[0], dtCurrent.getDayOfMonth());
    } else if (idx >= 0) {
      return dtCurrent.with(CATTLE_OPTION_EXPIRY_MONTHS[idx + 1]);
View Full Code Here

    final double cs01 = NOTIONAL * ONE_BP * CS01_CAL.parallelCS01(cds, new QuotedSpread(COUPON, tradelevel), yieldCurve, ONE_BP);
    System.out.println("CS01: " + cs01);

    final int day = 5;
    final Month month = Month.SEPTEMBER;
    for (int i = 0; i < 10; i++) {
      final int year = 2014 + i;
      final LocalDate mat = LocalDate.of(year, month, day);
      final double t = ACT365.getDayCountFraction(tradeDate, mat);
      final double df = yieldCurve.getDiscountFactor(t);
View Full Code Here

TOP

Related Classes of org.threeten.bp.Month

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.