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


Java Month类代码示例

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


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

示例1: getTradingMonths

import org.threeten.bp.Month; //导入依赖的package包/类
/**
 * Gets trading months (not static as depends on current date).
 * 
 * @param now  the date today, not null
 * @return the valid trading months, not null
 */
private Month[] getTradingMonths(final LocalDate now) {
  // this may need improvements as the year end approaches
  Set<Month> ret = new TreeSet<>();
  ret.add(now.getMonth()); // this month
  ret.add(now.getMonth().plus(1)); // next month
  ret.add(now.getMonth().plus(2)); // next 2 months
  //  February, April, August, and October in next 23 months
  ret.add(Month.FEBRUARY);
  ret.add(Month.APRIL);
  ret.add(Month.AUGUST);
  ret.add(Month.OCTOBER);
  // June and December falling in next 72 month period
  ret.add(Month.JUNE);
  ret.add(Month.DECEMBER);
  // assuming this gives enough valid dates so dont go round to next 12 month period
  return ret.toArray(new Month[0]);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:24,代码来源:GoldFutureExpiryCalculator.java

示例2: getExpiryDate

import org.threeten.bp.Month; //导入依赖的package包/类
@Override
/**
 * Quarterly expiries along March cycle
 * @param nthFuture nth future
 * @param valDate The date from which to start
 * @return the expiry date of the nth option
 */
public LocalDate getExpiryDate(int n, LocalDate today, Calendar holidayCalendar) {
  ArgumentChecker.notNegativeOrZero(n, "nth expiry");
  ArgumentChecker.notNull(today, "date");
  ArgumentChecker.notNull(holidayCalendar, "holidayCalendar");

  LocalDate thirdFriday = getThirdFriday(today, holidayCalendar);
  if (today.isAfter(thirdFriday)) { // If it is not on or after valuationDate...
    thirdFriday = getThirdFriday(today.plusMonths(1), holidayCalendar);
  }
  int nQuartersRemaining = QUARTERLY_CYCLE_MONTHS.contains(Month.from(thirdFriday)) ? n - 1 : n;
  if (nQuartersRemaining == 0) {
    return thirdFriday;
  }
  return getQuarterlyExpiry(nQuartersRemaining, thirdFriday, holidayCalendar);
  
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:24,代码来源:RussellFutureExpiryCalculator.java

示例3: makeEuroBundFuture

import org.threeten.bp.Month; //导入依赖的package包/类
public static BondFutureSecurity makeEuroBundFuture() {
  Expiry expiry = new Expiry(ZonedDateTime.of(LocalDateTime.of(2010, Month.JUNE, 8, 21, 0), ZoneOffset.UTC),
                             ExpiryAccuracy.MIN_HOUR_DAY_MONTH_YEAR);
  Set<BondFutureDeliverable> basket = new HashSet<>();
  basket.add(new BondFutureDeliverable(ExternalIdBundle.of(
      ExternalSchemes.bloombergBuidSecurityId("COEH8262261")), 0.828936d));
  basket.add(new BondFutureDeliverable(ExternalIdBundle.of(
      ExternalSchemes.bloombergBuidSecurityId("COEI0354262")), 0.80371d));
  basket.add(new BondFutureDeliverable(ExternalIdBundle.of(
      ExternalSchemes.bloombergBuidSecurityId("COEI2292098")), 0.777869d));
  basket.add(new BondFutureDeliverable(ExternalIdBundle.of(
      ExternalSchemes.bloombergBuidSecurityId("COEH6142705")), 0.852328d));
  
  BondFutureSecurity sec = new BondFutureSecurity(expiry, "XEUR", "XEUR", EUR, 1000, basket,
                                                  LocalDateTime.of(2010, 6, 10, 0, 0, 0, 0).atZone(ZoneOffset.UTC), 
                                                  LocalDateTime.of(2010, 6, 10, 0, 0, 0, 0).atZone(ZoneOffset.UTC),
                                                  "BOND");
  sec.setName("EURO-BUND FUTURE Jun10");
  Set<ExternalId> identifiers = new HashSet<>();
  identifiers.add(ExternalSchemes.bloombergBuidSecurityId("IX9439039-0"));
  identifiers.add(ExternalSchemes.cusipSecurityId("RXM10"));
  identifiers.add(ExternalSchemes.bloombergTickerSecurityId("RXM10 Comdty"));
  sec.setExternalIdBundle(ExternalIdBundle.of(identifiers));
  return sec;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:26,代码来源:BloombergSecurityUtils.java

示例4: getSchedule

import org.threeten.bp.Month; //导入依赖的package包/类
public LocalDate[] getSchedule(final LocalDate startDate, final LocalDate endDate) {
  ArgumentChecker.notNull(startDate, "start date");
  ArgumentChecker.notNull(endDate, "end date");
  ArgumentChecker.isFalse(startDate.isAfter(endDate), "start date must not be after end date");
  if (startDate.equals(endDate)) {
    if (startDate.getDayOfMonth() == 31 && startDate.getMonth() == Month.DECEMBER) {
      return new LocalDate[] {startDate};
    }
    throw new IllegalArgumentException("Start date and end date were the same but neither was the last day of the year");
  }
  final List<LocalDate> dates = new ArrayList<>();
  LocalDate date = startDate.with(TemporalAdjusters.lastDayOfYear());
  while (!date.isAfter(endDate)) {
    dates.add(date);
    date = date.plusYears(1).with(TemporalAdjusters.lastDayOfYear());
  }
  return dates.toArray(EMPTY_LOCAL_DATE_ARRAY);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:19,代码来源:EndOfYearScheduleCalculator.java

示例5: parseIdentifiers

import org.threeten.bp.Month; //导入依赖的package包/类
@Test
public void parseIdentifiers() throws Exception {
  Set<ExternalIdWithDates> identifiers = Sets.newHashSet(
      ExternalIdWithDates.of(ExternalSchemes.bloombergTickerSecurityId("EDU0 Comdty"),
          LocalDate.of(2010, Month.SEPTEMBER, 14), LocalDate.of(2020, Month.SEPTEMBER, 14)),
      ExternalIdWithDates.of(ExternalSchemes.bloombergBuidSecurityId("IX11084074-0"), null, null),
      ExternalIdWithDates.of(ExternalSchemes.cusipSecurityId("EDU0"), null, null));

  ExternalIdBundleWithDates expected = new ExternalIdBundleWithDates(identifiers);
  
  MutableFudgeMsg message = new FudgeContext().newMessage();
  message.add(FIELD_ID_BBG_UNIQUE, "IX11084074-0");
  message.add(FIELD_ID_CUSIP, "EDU0");
  message.add(FIELD_PARSEKYABLE_DES, "EDU0 Comdty");
  message.add(FIELD_FUT_FIRST_TRADE_DT, "2010-09-14");
  message.add(FIELD_FUT_LAST_TRADE_DT, "2020-09-14");
  
  ExternalIdBundleWithDates actual = BloombergDataUtils.parseIdentifiers(message, FIELD_FUT_FIRST_TRADE_DT, FIELD_FUT_LAST_TRADE_DT);
  assertEquals(expected, actual);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:21,代码来源:BloombergDataUtilsTest.java

示例6: getSchedule

import org.threeten.bp.Month; //导入依赖的package包/类
public LocalDate[] getSchedule(final LocalDate startDate, final LocalDate endDate) {
  ArgumentChecker.notNull(startDate, "start date");
  ArgumentChecker.notNull(endDate, "end date");
  ArgumentChecker.isFalse(startDate.isAfter(endDate), "start date must not be after end date");
  if (startDate.equals(endDate)) {
    if (startDate.getDayOfMonth() == 1 && startDate.getMonth() == Month.JANUARY) {
      return new LocalDate[] {startDate};
    }
    throw new IllegalArgumentException("Start date and end date were the same but neither was the first day of the year");
  }
  final List<LocalDate> dates = new ArrayList<>();
  LocalDate date = startDate.with(TemporalAdjusters.firstDayOfYear());
  if (date.isBefore(startDate)) {
    date = date.plusYears(1);
  }
  while (!date.isAfter(endDate)) {
    dates.add(date);
    date = date.plusYears(1);
  }
  return dates.toArray(EMPTY_LOCAL_DATE_ARRAY);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:22,代码来源:FirstOfYearScheduleCalculator.java

示例7: getDayCountFraction

import org.threeten.bp.Month; //导入依赖的package包/类
@Override
public double getDayCountFraction(final LocalDate firstDate, final LocalDate secondDate) {
  testDates(firstDate, secondDate);
  final long daysBetween = firstDate.periodUntil(secondDate, DAYS);
  final LocalDate oneYear = firstDate.plusYears(1);
  if (secondDate.isBefore(oneYear) || oneYear.equals(secondDate)) {
    final double daysInYear = secondDate.isLeapYear() && secondDate.getMonthValue() > 2 ? 366 : 365;
    return daysBetween / daysInYear;
  }
  final LocalDate[] schedule = ScheduleFactory.getSchedule(firstDate, secondDate, 1, true, true, false);
  LocalDate d = schedule[0];
  if (d.isLeapYear() && d.getMonth() == Month.FEBRUARY && d.getDayOfMonth() == 28) {
    d = d.plusDays(1);
  }
  return schedule.length - 1.0 + getDayCountFraction(firstDate, d);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:17,代码来源:ActualActualAFB.java

示例8: accruedInterestTest

import org.threeten.bp.Month; //导入依赖的package包/类
@Test
public void accruedInterestTest() {

  final LocalDate accStart = LocalDate.of(2011, Month.MARCH, 21);
  final LocalDate maturity = LocalDate.of(2011, Month.SEPTEMBER, 20);

  LocalDate tradeDate = LocalDate.of(2011, Month.JUNE, 18);
  CDSAnalytic cds = FACTORY.makeCDS(tradeDate, accStart, maturity);
  assertEquals(90, cds.getAccuredDays());

  tradeDate = LocalDate.of(2011, Month.JUNE, 19);
  cds = FACTORY.makeCDS(tradeDate, accStart, maturity);
  assertEquals(0, cds.getAccuredDays());

  tradeDate = LocalDate.of(2011, Month.JUNE, 20);
  cds = FACTORY.makeCDS(tradeDate, accStart, maturity);
  assertEquals(1, cds.getAccuredDays());
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:19,代码来源:CDSAnalyticTest.java

示例9: bucketedCS01Test2

import org.threeten.bp.Month; //导入依赖的package包/类
@Test(enabled = false)
public void bucketedCS01Test2() {

  final String[] matString = new String[] {"20/09/2013", "20/12/2013", "20/03/2014", "20/06/2014", "20/09/2014", "20/12/2014", "20/03/2015", "20/06/2015", "20/09/2015", "20/12/2015", "20/03/2016",
    "20/06/2016", "20/09/2016", "20/12/2016", "20/03/2017", "20/06/2017", "20/09/2017", "20/12/2017", "20/03/2018", "20/06/2018", "20/09/2018", "20/12/2018", "20/03/2019", "20/06/2019",
    "20/09/2019", "20/12/2019", "20/03/2020", "20/06/2020", "20/09/2020", "20/12/2020", "20/03/2021", "20/06/2021", "20/09/2021", "20/12/2021", "20/03/2022", "20/06/2022", "20/09/2022",
    "20/12/2022", "20/03/2023", "20/06/2023", "20/09/2023" };
  final LocalDate[] mats = parseDateStrings(matString);
  final LocalDate tradeDate = LocalDate.of(2013, Month.SEPTEMBER, 14); //Today 
  final LocalDate accStart = LocalDate.of(2013, Month.JUNE, 20);
  final double notional = 1e6;
  final double scale = notional * ONE_BP;
  final double[] puf = new double[] {3.53, 6.25, 7.28, 12.28, 15, 18.62, 20.32, 22.52, 26.55, 28.67, 27.26, 30.26, 29.84, 31.56, 30.94, 31.94, 33.6, 33.94, 33.41, 33.65, 35.83, 34.52, 36.58, 34.61,
    35.06, 36.36, 37.47, 36.97, 37.91, 37.33, 36.88, 37.03, 37.58, 38.96, 38.78, 39.71, 38.87, 38.8, 38.68, 38.17, 38.3 };
  final double coupon = 0.05;
  final CDSAnalyticFactory factory = new CDSAnalyticFactory(RECOVERY_RATE);

  final CDSAnalytic[] cds = factory.makeCDS(tradeDate, accStart, mats);
  final CDSAnalytic[] buckets = factory.makeIMMCDS(tradeDate, BUCKETS);
  final int n = cds.length;
  final double[][] cs01 = new double[n][];
  for (int i = 0; i < n; i++) {
    cs01[i] = CS01_CAL.bucketedCS01FromPUF(cds[i], new PointsUpFront(coupon, puf[i] * ONE_PC), YIELD_CURVE, buckets, ONE_BP);
  }
  print(cs01, scale);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:27,代码来源:CS01FromPUFTest.java

示例10: assertExpiry

import org.threeten.bp.Month; //导入依赖的package包/类
private void assertExpiry (Month expected, int expectedDay, int expectedYear, 
                           LocalDate referenceDate, int monthsFromReferenceDate, 
                           BloombergEQVanillaOptionChain chain) {
  LocalDate expectedValue = LocalDate.of(expectedYear, expected, expectedDay);
  
  StringBuilder sb = new StringBuilder();
  sb.append ("[ FAIL : referenceDate = ").append(referenceDate)
    .append (" | months = ").append(monthsFromReferenceDate);
  
  StringBuilder sb2 = new StringBuilder(sb).append(" | Chain is empty ]");    
  assertTrue(sb2.toString(), chain.getIdentifiers().size() > 0);
  
  StringBuilder sb3 = new StringBuilder(sb).append(" | expected expiry = ").append(expectedValue);
  for (ExternalId identifier : chain.getIdentifiers()) {      
    BloombergTickerParserEQVanillaOption parser = new BloombergTickerParserEQVanillaOption(identifier);
    LocalDate actual = parser.getExpiry();
    sb3.append(" | actual expiry = ").append(actual).append(" ]");
    assertEquals (sb3.toString(), expectedValue, actual);
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:21,代码来源:BloombergEQVanillaOptionChainTest.java

示例11: test

import org.threeten.bp.Month; //导入依赖的package包/类
@Test
public void test() {
  assertEquals(ScheduleCalculatorFactory.getScheduleCalculator(ScheduleCalculatorFactory.DAILY), ScheduleCalculatorFactory.DAILY_CALCULATOR);
  assertEquals(ScheduleCalculatorFactory.getScheduleCalculator(ScheduleCalculatorFactory.WEEKLY), ScheduleCalculatorFactory.WEEKLY_CALCULATOR);
  assertEquals(ScheduleCalculatorFactory.getScheduleCalculator(ScheduleCalculatorFactory.MONTHLY), ScheduleCalculatorFactory.MONTHLY_CALCULATOR);
  assertEquals(ScheduleCalculatorFactory.getScheduleCalculator(ScheduleCalculatorFactory.FIRST_OF_MONTH), ScheduleCalculatorFactory.FIRST_OF_MONTH_CALCULATOR);
  assertEquals(ScheduleCalculatorFactory.getScheduleCalculator(ScheduleCalculatorFactory.END_OF_MONTH), ScheduleCalculatorFactory.END_OF_MONTH_CALCULATOR);
  assertEquals(ScheduleCalculatorFactory.getScheduleCalculator(ScheduleCalculatorFactory.QUARTERLY), ScheduleCalculatorFactory.QUARTERLY_CALCULATOR);
  assertEquals(ScheduleCalculatorFactory.getScheduleCalculator(ScheduleCalculatorFactory.QUARTERLY_EOM), ScheduleCalculatorFactory.QUARTERLY_EOM_CALCULATOR);
  assertEquals(ScheduleCalculatorFactory.getScheduleCalculator(ScheduleCalculatorFactory.SEMI_ANNUAL), ScheduleCalculatorFactory.SEMI_ANNUAL_CALCULATOR);
  assertEquals(ScheduleCalculatorFactory.getScheduleCalculator(ScheduleCalculatorFactory.SEMI_ANNUAL_EOM), ScheduleCalculatorFactory.SEMI_ANNUAL_EOM_CALCULATOR);
  assertEquals(ScheduleCalculatorFactory.getScheduleCalculator(ScheduleCalculatorFactory.ANNUAL), ScheduleCalculatorFactory.ANNUAL_CALCULATOR);
  assertEquals(ScheduleCalculatorFactory.getScheduleCalculator(ScheduleCalculatorFactory.FIRST_OF_YEAR), ScheduleCalculatorFactory.FIRST_OF_YEAR_CALCULATOR);
  assertEquals(ScheduleCalculatorFactory.getScheduleCalculator(ScheduleCalculatorFactory.END_OF_YEAR), ScheduleCalculatorFactory.END_OF_YEAR_CALCULATOR);
  assertEquals(ScheduleCalculatorFactory.getScheduleCalculator(ScheduleCalculatorFactory.ANNUAL_EOM), ScheduleCalculatorFactory.ANNUAL_EOM_CALCULATOR);
  assertEquals(ScheduleCalculatorFactory.getScheduleCalculator(ScheduleCalculatorFactory.WEEKLY_ON_DAY, DayOfWeek.MONDAY), new WeeklyScheduleOnDayCalculator(DayOfWeek.MONDAY));
  assertEquals(ScheduleCalculatorFactory.getScheduleCalculator(ScheduleCalculatorFactory.ANNUAL_ON_DAY_AND_MONTH, 11, Month.APRIL), new AnnualScheduleOnDayAndMonthCalculator(11,
      Month.APRIL));
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:20,代码来源:ScheduleCalculatorFactoryTest.java

示例12: toFutureExternalId

import org.threeten.bp.Month; //导入依赖的package包/类
public ExternalId toFutureExternalId(Integer month, Integer year) {
  ArgumentChecker.notNull(month, "month");
  ArgumentChecker.notNull(year, "year");
  
  ExternalId futureId = null;
  String futureMonthCode = BloombergDataUtils.futureMonthCode(Month.of(month));
  if (futureMonthCode != null) {
    String yearStr = String.valueOf(year);
    if (yearStr.length() > 1) {
      yearStr = "" + yearStr.charAt(yearStr.length() - 1);
    }
    futureId = ExternalSchemes.bloombergTickerSecurityId(String.format("%s%s%s %s", 
        getContractCode(), futureMonthCode, yearStr, getMarketSector()).toUpperCase());
  } else {
    s_logger.warn("Unable to resolve month {} to its future month's code", Month.of(month));
  }
  return futureId;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:19,代码来源:BloombergContractID.java

示例13: toFutureOptionExternalId

import org.threeten.bp.Month; //导入依赖的package包/类
public ExternalId toFutureOptionExternalId(Integer month, Integer year, Double strike, OptionType optionType) {
  ArgumentChecker.notNull(month, "month");
  ArgumentChecker.notNull(year, "year");
  ArgumentChecker.notNull(strike, "strike");
  ArgumentChecker.notNull(optionType, "optionType");
  
  ExternalId optionId = null;
  String monthCode = BloombergDataUtils.futureMonthCode(Month.of(month));
  if (monthCode != null) {
    String yearStr = String.valueOf(year);
    if (yearStr.length() > 1) {
      yearStr = "" + yearStr.charAt(yearStr.length() - 1);
    }
    optionId = ExternalSchemes.bloombergTickerSecurityId(String.format("%s%s%s%s %s %s", 
        getContractCode(), monthCode, yearStr, optionType.name().charAt(0), getRoundedPrice(strike, 3), getMarketSector()).toUpperCase());
  } else {
    s_logger.warn("Unable to resolve month {} to its future month's code", Month.of(month));
  }
  return optionId;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:21,代码来源:BloombergContractID.java

示例14: getListOfDaysBetweenTwoDates

import org.threeten.bp.Month; //导入依赖的package包/类
@Test
public void getListOfDaysBetweenTwoDates() {
  List<LocalDate> expectedList = IntStream.range(22, 30)
      .mapToObj(day -> LocalDate.of(2016, Month.AUGUST, day))
      .collect(Collectors.toList());

  List<LocalDate> listOfDaysBetweenTwoDates =
      DateHelper.getListOfDaysBetweenTwoDates(LOCAL_DATE_22nd_AUG_2016, LOCAL_DATE_29th_AUG_2016);

  assertThat(expectedList, equalTo(listOfDaysBetweenTwoDates));
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:12,代码来源:DateHelperTest.java

示例15: getListOfDaysBetweenTwoWeeks

import org.threeten.bp.Month; //导入依赖的package包/类
@Test
public void getListOfDaysBetweenTwoWeeks() {
  LocalDate firstDayOfWeek = LOCAL_DATE_22nd_AUG_2016;
  LocalDate end = firstDayOfWeek.plusWeeks(1).plusDays(-1);

  List<LocalDate> expectedList = IntStream.range(22, 29)
      .mapToObj(day -> LocalDate.of(2016, Month.AUGUST, day))
      .collect(Collectors.toList());

  List<LocalDate> listOfDaysBetweenTwoDates = DateHelper.getListOfDaysBetweenTwoDates(firstDayOfWeek, end);

  assertThat(expectedList, equalTo(listOfDaysBetweenTwoDates));
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:14,代码来源:DateHelperTest.java


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