本文整理汇总了Java中net.objectlab.kit.datecalc.common.DefaultHolidayCalendar类的典型用法代码示例。如果您正苦于以下问题:Java DefaultHolidayCalendar类的具体用法?Java DefaultHolidayCalendar怎么用?Java DefaultHolidayCalendar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultHolidayCalendar类属于net.objectlab.kit.datecalc.common包,在下文中一共展示了DefaultHolidayCalendar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AbstractCurrencyDateCalculator
import net.objectlab.kit.datecalc.common.DefaultHolidayCalendar; //导入依赖的package包/类
protected AbstractCurrencyDateCalculator(final CurrencyDateCalculatorBuilder<E> builder) {
builder.checkValidity();
this.ccy1 = builder.getCcy1();
this.ccy2 = builder.getCcy2();
this.crossCcy = builder.getCrossCcy();
this.ccy1HolidayCalendar = new ImmutableHolidayCalendar<E>(
builder.getCcy1Calendar() != null ? builder.getCcy1Calendar() : new DefaultHolidayCalendar<E>());
this.ccy2HolidayCalendar = new ImmutableHolidayCalendar<E>(
builder.getCcy2Calendar() != null ? builder.getCcy2Calendar() : new DefaultHolidayCalendar<E>());
this.crossCcyHolidayCalendar = new ImmutableHolidayCalendar<E>(
builder.getCrossCcyCalendar() != null ? builder.getCrossCcyCalendar() : new DefaultHolidayCalendar<E>());
this.holidayHandler = builder.getTenorHolidayHandler();
this.ccy1Week = builder.getCcy1Week();
this.ccy2Week = builder.getCcy2Week();
this.crossCcyWeek = builder.getCrossCcyWeek();
this.brokenDateAllowed = builder.isBrokenDateAllowed();
this.spotLag = builder.getSpotLag();
this.adjustStartDateWithCcy1Ccy2 = builder.isAdjustStartDateWithCurrencyPair();
this.useCrossCcyOnT1ForCcy1 = builder.getCurrencyCalculatorConfig() != null
&& builder.getCurrencyCalculatorConfig().getCurrenciesSubjectToCrossCcyForT1(crossCcy).contains(ccy1);
this.useCrossCcyOnT1ForCcy2 = builder.getCurrencyCalculatorConfig() != null
&& builder.getCurrencyCalculatorConfig().getCurrenciesSubjectToCrossCcyForT1(crossCcy).contains(ccy2);
}
示例2: example2EURHolidays
import net.objectlab.kit.datecalc.common.DefaultHolidayCalendar; //导入依赖的package包/类
private static void example2EURHolidays() {
final Set<LocalDate> holidays = new HashSet<LocalDate>();
holidays.add(new LocalDate("2014-07-03"));
// create the HolidayCalendar ASSUMING that the set covers 2006!
final HolidayCalendar<LocalDate> eurCalendar = new DefaultHolidayCalendar<LocalDate>(holidays, new LocalDate("2014-01-01"), new LocalDate(
"2014-12-31"));
final CurrencyDateCalculatorBuilder<LocalDate> builder = new CurrencyDateCalculatorBuilder<LocalDate>() //
.currencyPair("EUR", "USD", SpotLag.T_2) //
.ccy1Calendar(eurCalendar) //
.tenorHolidayHandler(new LocalDateForwardHandler()) // Forward
// Will be used for finding Working Weeks if not provided and Latin American ccy USD handling.
.currencyCalculatorConfig(new DefaultCurrencyCalculatorConfig());
final LocalDateCurrencyDateCalculator calc = new LocalDateCurrencyDateCalculator(builder);
final LocalDate startDate = new LocalDate(2014, 7, 1);
System.out.println(calc.getName() + " Ex2 EUR holiday TD: " + startDate + " Calculated Spot " + calc.calculateSpotDate(startDate)
+ " expects 4 Jul");
}
示例3: example3USDEURHolidays
import net.objectlab.kit.datecalc.common.DefaultHolidayCalendar; //导入依赖的package包/类
private static void example3USDEURHolidays() {
final Set<LocalDate> holidays = new HashSet<LocalDate>();
holidays.add(new LocalDate("2014-07-03"));
// create the HolidayCalendar ASSUMING that the set covers 2006!
final HolidayCalendar<LocalDate> eurCalendar = new DefaultHolidayCalendar<LocalDate>(holidays, new LocalDate("2014-01-01"), new LocalDate(
"2014-12-31"));
final Set<LocalDate> holidays2 = new HashSet<LocalDate>();
holidays2.add(new LocalDate("2014-07-04"));
// create the HolidayCalendar ASSUMING that the set covers 2006!
final HolidayCalendar<LocalDate> usdCalendar = new DefaultHolidayCalendar<LocalDate>(holidays2, new LocalDate("2014-01-01"), new LocalDate(
"2014-12-31"));
final CurrencyDateCalculatorBuilder<LocalDate> builder = new CurrencyDateCalculatorBuilder<LocalDate>() //
.currencyPair("EUR", "USD", SpotLag.T_2) //
.ccy1Calendar(eurCalendar) //
.ccy2Calendar(usdCalendar) //
.tenorHolidayHandler(new LocalDateForwardHandler()) // Forward
// Will be used for finding Working Weeks if not provided and Latin American ccy USD handling.
.currencyCalculatorConfig(new DefaultCurrencyCalculatorConfig());
final LocalDateCurrencyDateCalculator calc = new LocalDateCurrencyDateCalculator(builder);
final LocalDate startDate = new LocalDate(2014, 7, 1);
System.out.println(calc.getName() + " Ex3 USD+EUR holiday TD: " + startDate + " Calculated Spot " + calc.calculateSpotDate(startDate)
+ " expects 7 Jul");
}
示例4: crossGbpJpyWithHolidays
import net.objectlab.kit.datecalc.common.DefaultHolidayCalendar; //导入依赖的package包/类
private static void crossGbpJpyWithHolidays() {
final Set<LocalDate> gbpHholidays = new HashSet<LocalDate>();
gbpHholidays.add(new LocalDate("2014-08-04"));
final HolidayCalendar<LocalDate> gbpCalendar = new DefaultHolidayCalendar<LocalDate>(gbpHholidays, new LocalDate("2014-01-01"),
new LocalDate("2014-12-31"));
LocalDateKitCalculatorsFactory.getDefaultInstance().registerHolidays("GBP", gbpCalendar);
final Set<LocalDate> jpyHolidays = new HashSet<LocalDate>();
jpyHolidays.add(new LocalDate("2014-08-05"));
final HolidayCalendar<LocalDate> jpyCalendar = new DefaultHolidayCalendar<LocalDate>(jpyHolidays, new LocalDate("2014-01-01"), new LocalDate(
"2014-12-31"));
LocalDateKitCalculatorsFactory.getDefaultInstance().registerHolidays("JPY", jpyCalendar);
final LocalDateCurrencyDateCalculator calc = LocalDateKitCalculatorsFactory.forwardCurrencyDateCalculator("GBP", "JPY", SpotLag.T_2);
// set startDate, this will also set the current business date.
final LocalDate startDate = new LocalDate(2014, 8, 1); // Friday
System.out.println(calc.getName() + " TD: " + startDate + " Spot " + calc.calculateSpotDate(startDate) + " expects 6 Aug");
}
示例5: crossEurMxn
import net.objectlab.kit.datecalc.common.DefaultHolidayCalendar; //导入依赖的package包/类
private static void crossEurMxn() {
final Set<LocalDate> holidays = new HashSet<LocalDate>();
holidays.add(new LocalDate("2006-07-04"));
// create the HolidayCalendar ASSUMING that the set covers 2006!
final HolidayCalendar<LocalDate> usdCalendar = new DefaultHolidayCalendar<LocalDate>(holidays, new LocalDate("2006-01-01"), new LocalDate(
"2006-12-31"));
final CurrencyDateCalculatorBuilder<LocalDate> builder = new CurrencyDateCalculatorBuilder<LocalDate>() //
.currencyPair("EUR", "MXN", SpotLag.T_2) //
.currencyCalculatorConfig(new DefaultCurrencyCalculatorConfig())//
.crossCcyCalendar(usdCalendar) //
.tenorHolidayHandler(new LocalDateForwardHandler());
final LocalDateCurrencyDateCalculator calc = new LocalDateCurrencyDateCalculator(builder);
LocalDate startDate = new LocalDate(2006, 6, 30);
System.out.println(calc.getName() + " TD: " + startDate + " Spot " + calc.calculateSpotDate(startDate) + " expects 5 Jul");
startDate = new LocalDate(2006, 7, 2);
System.out.println(calc.getName() + " TD: " + startDate + " Spot " + calc.calculateSpotDate(startDate) + " expects 6 Jul");
startDate = new LocalDate(2006, 7, 3);
System.out.println(calc.getName() + " TD: " + startDate + " Spot " + calc.calculateSpotDate(startDate) + " expects 6 Jul");
}
示例6: simpleEurUsd
import net.objectlab.kit.datecalc.common.DefaultHolidayCalendar; //导入依赖的package包/类
private static void simpleEurUsd() {
final Set<LocalDate> holidays = new HashSet<LocalDate>();
holidays.add(new LocalDate("2006-07-04"));
// create the HolidayCalendar ASSUMING that the set covers 2006!
final HolidayCalendar<LocalDate> usdCalendar = new DefaultHolidayCalendar<LocalDate>(holidays, new LocalDate("2006-01-01"), new LocalDate(
"2006-12-31"));
final CurrencyDateCalculatorBuilder<LocalDate> builder = new CurrencyDateCalculatorBuilder<LocalDate>() //
.currencyPair("EUR", CurrencyDateCalculator.USD_CODE, SpotLag.T_2) //
.currencyCalculatorConfig(new DefaultCurrencyCalculatorConfig())//
.crossCcyCalendar(usdCalendar) //
.ccy2Calendar(usdCalendar)//
.tenorHolidayHandler(new LocalDateForwardHandler());
final LocalDateCurrencyDateCalculator calc = new LocalDateCurrencyDateCalculator(builder);
LocalDate startDate = new LocalDate(2006, 6, 30);
System.out.println(calc.getName() + " TD: " + startDate + " Spot " + calc.calculateSpotDate(startDate) + " expects 5 Jul");
startDate = new LocalDate(2006, 7, 2);
System.out.println(calc.getName() + " TD: " + startDate + " Spot " + calc.calculateSpotDate(startDate) + " expects 5 Jul");
startDate = new LocalDate(2006, 7, 3);
System.out.println(calc.getName() + " TD: " + startDate + " Spot " + calc.calculateSpotDate(startDate) + " expects 5 Jul");
}
示例7: simpleAudUsd
import net.objectlab.kit.datecalc.common.DefaultHolidayCalendar; //导入依赖的package包/类
private static void simpleAudUsd() {
final Set<LocalDate> holidays = new HashSet<LocalDate>();
holidays.add(new LocalDate("2015-01-19"));
final HolidayCalendar<LocalDate> usdCalendar = new DefaultHolidayCalendar<LocalDate>(holidays, new LocalDate("2006-01-01"), new LocalDate(
"2015-12-31"));
final CurrencyDateCalculatorBuilder<LocalDate> builder = new CurrencyDateCalculatorBuilder<LocalDate>() //
.currencyPair("AUD", CurrencyDateCalculator.USD_CODE, SpotLag.T_2) //
.currencyCalculatorConfig(new DefaultCurrencyCalculatorConfig())//
.ccy2Calendar(usdCalendar)//
.tenorHolidayHandler(new LocalDateForwardHandler());
final LocalDateCurrencyDateCalculator calc = new LocalDateCurrencyDateCalculator(builder);
LocalDate startDate = new LocalDate(2015, 1, 16);
System.out.println(calc.getName() + " TD: " + startDate + " Spot " + calc.calculateSpotDate(startDate) + " expects 20 Jan");
}
示例8: crossEurGbp
import net.objectlab.kit.datecalc.common.DefaultHolidayCalendar; //导入依赖的package包/类
private static void crossEurGbp() {
final Set<LocalDate> holidays = new HashSet<LocalDate>();
holidays.add(new LocalDate("2006-07-04"));
// create the HolidayCalendar ASSUMING that the set covers 2006!
final HolidayCalendar<LocalDate> usdCalendar = new DefaultHolidayCalendar<LocalDate>(holidays, new LocalDate("2006-01-01"), new LocalDate(
"2006-12-31"));
final CurrencyDateCalculatorBuilder<LocalDate> builder = new CurrencyDateCalculatorBuilder<LocalDate>() //
.currencyPair("EUR", "GBP", SpotLag.T_2) //
.currencyCalculatorConfig(new DefaultCurrencyCalculatorConfig())//
.crossCcyCalendar(usdCalendar) //
.tenorHolidayHandler(new LocalDateForwardHandler());
final LocalDateCurrencyDateCalculator calc = new LocalDateCurrencyDateCalculator(builder);
LocalDate startDate = new LocalDate(2006, 7, 2);
System.out.println(calc.getName() + " TD: " + startDate + " Spot " + calc.calculateSpotDate(startDate) + " expects 5 Jul");
startDate = new LocalDate(2006, 6, 30);
System.out.println(calc.getName() + " TD: " + startDate + " Spot " + calc.calculateSpotDate(startDate) + " expects 5 Jul");
}
示例9: WORKDAY
import net.objectlab.kit.datecalc.common.DefaultHolidayCalendar; //导入依赖的package包/类
/**
* Returns a date number that can be formatted as a date. You then see the date of a day that is a certain number of
* Workdays away from the start_date. Holidays (optional) is a list of holidays. Enter a cell range in which the
* holidays are listed individually.
*/
public ReadablePartial WORKDAY(ReadablePartial startDate, int days, Iterator<ReadablePartial> holidays) {
Set<LocalDate> holidaySet = new HashSet<LocalDate>();
if (holidays != null) {
while (holidays.hasNext()) {
holidaySet.add(DateUtils.toLocalDate(holidays.next(), ORIGIN_DATE));
}
}
HolidayCalendar<LocalDate> holidayCalendar = new DefaultHolidayCalendar<LocalDate>(holidaySet);
DateCalculator<LocalDate> calc = new LocalDateCalculator("", DateUtils.toLocalDate(startDate, ORIGIN_DATE),
holidayCalendar, null);
calc = calc.moveByBusinessDays(days);
return calc.getCurrentBusinessDate();
}
示例10: testGetHolidays
import net.objectlab.kit.datecalc.common.DefaultHolidayCalendar; //导入依赖的package包/类
public void testGetHolidays() {
final Set<LocalDate> holidays = new HashSet<LocalDate>();
holidays.add(new LocalDate("2009-04-22"));
holidays.add(new LocalDate("2010-04-22"));
final HolidayCalendar<LocalDate> holidayCalendar = new DefaultHolidayCalendar<LocalDate>(holidays, new LocalDate("2009-01-01"),
new LocalDate("2009-12-01"));
assertTrue(holidayCalendar.getHolidays().size() == 2);
}
示例11: testIsHoliday
import net.objectlab.kit.datecalc.common.DefaultHolidayCalendar; //导入依赖的package包/类
public void testIsHoliday() {
final Set<LocalDate> holidays = new HashSet<LocalDate>();
final LocalDate holiday = new LocalDate("2009-04-22");
holidays.add(holiday);
final HolidayCalendar<LocalDate> holidayCalendar = new DefaultHolidayCalendar<LocalDate>(holidays, new LocalDate("2009-01-01"),
new LocalDate("2009-12-01"));
final LocalDate testHoliday = new LocalDate(2009, 4, 22);
assertTrue(holidayCalendar.isHoliday(testHoliday));
assertFalse(holidayCalendar.isHoliday(new LocalDate(2009, 4, 21)));
}
示例12: testForDateWithDifferentChronologies
import net.objectlab.kit.datecalc.common.DefaultHolidayCalendar; //导入依赖的package包/类
/**
* See JODA issue:
* http://joda-interest.219941.n2.nabble.com/LocalDate-equals-method-bug-td7572429.html
*/
public void testForDateWithDifferentChronologies() {
final LocalDate localDate2 = new LocalDate(2012, 6, 21);
final Set<LocalDate> s = new HashSet<LocalDate>();
s.add(localDate2);
final HolidayCalendar<LocalDate> holidayCalendar = new DefaultHolidayCalendar<LocalDate>(s, new LocalDate("2009-01-01"), new LocalDate(
"2009-12-01"));
assertTrue("Date with Chronology " + localDate2.getChronology(), holidayCalendar.isHoliday(localDate2));
final DateTimeFormatter dateTimeFormat = DateTimeFormat.forPattern("yyyyMMdd HH:mm");
final Calendar calendar = dateTimeFormat.parseDateTime("20120621 09:00").toCalendar(null);
final LocalDate localDate1 = new LocalDate(calendar);
assertTrue("Date with Chronology " + localDate1.getChronology(), holidayCalendar.isHoliday(localDate1));
}
示例13: simpleEurUsd
import net.objectlab.kit.datecalc.common.DefaultHolidayCalendar; //导入依赖的package包/类
private static void simpleEurUsd() {
final Set<LocalDate> holidays = new HashSet<LocalDate>();
holidays.add(new LocalDate("2006-07-04"));
// create the HolidayCalendar ASSUMING that the set covers 2006!
final HolidayCalendar<LocalDate> usdCalendar = new DefaultHolidayCalendar<LocalDate>(holidays, new LocalDate("2006-01-01"), new LocalDate(
"2006-12-31"));
final CurrencyDateCalculatorBuilder<LocalDate> builder = new CurrencyDateCalculatorBuilder<LocalDate>() //
.currencyPair("EUR", "USD", SpotLag.T_2) //
.ccy1Calendar(new DefaultHolidayCalendar<LocalDate>()) // empty
.ccy1Week(WorkingWeek.DEFAULT) // Mon-Fri
.ccy2Calendar(usdCalendar) //
.ccy2Week(WorkingWeek.DEFAULT) // Mon-Fri
.crossCcyCalendar(usdCalendar) //
.crossCcyWeek(WorkingWeek.DEFAULT) // Mon-Fri;
.adjustStartDateWithCurrencyPair(true) // default is true, Move the startDate to a working date for ccy1 and ccy2
.tenorHolidayHandler(new LocalDateForwardHandler()) // Forward
.brokenDateAllowed(true) // use USD holidays on Spot Date
.currencyCalculatorConfig(new DefaultCurrencyCalculatorConfig()) // Will be used for finding Working Weeks if not provided and Latin
// American ccy USD handling.
;
final LocalDateCurrencyDateCalculator calc = new LocalDateCurrencyDateCalculator(builder);
LocalDate startDate = new LocalDate(2006, 6, 30);
System.out.println(calc.getName() + " TD: " + startDate + " Spot " + calc.calculateSpotDate(startDate) + " expects 5 Jul");
startDate = new LocalDate(2006, 7, 2);
System.out.println(calc.getName() + " TD: " + startDate + " Spot " + calc.calculateSpotDate(startDate) + " expects 5 Jul");
startDate = new LocalDate(2006, 7, 3);
System.out.println(calc.getName() + " TD: " + startDate + " Spot " + calc.calculateSpotDate(startDate) + " expects 5 Jul");
}
示例14: testGetHolidays
import net.objectlab.kit.datecalc.common.DefaultHolidayCalendar; //导入依赖的package包/类
public void testGetHolidays() {
final Set<LocalDate> holidays = new HashSet<>();
holidays.add(LocalDate.parse("2009-04-22"));
holidays.add(LocalDate.parse("2010-04-22"));
final HolidayCalendar<LocalDate> holidayCalendar = new DefaultHolidayCalendar<>(holidays, LocalDate.parse("2009-01-01"),
LocalDate.parse("2009-12-01"));
assertTrue(holidayCalendar.getHolidays().size() == 2);
}
示例15: testIsHoliday
import net.objectlab.kit.datecalc.common.DefaultHolidayCalendar; //导入依赖的package包/类
public void testIsHoliday() {
final Set<LocalDate> holidays = new HashSet<>();
final LocalDate holiday = LocalDate.parse("2009-04-22");
holidays.add(holiday);
final HolidayCalendar<LocalDate> holidayCalendar = new DefaultHolidayCalendar<>(holidays, LocalDate.parse("2009-01-01"),
LocalDate.parse("2009-12-01"));
final LocalDate testHoliday = LocalDate.parse("2009-04-22");
assertTrue(holidayCalendar.isHoliday(testHoliday));
assertFalse(holidayCalendar.isHoliday(LocalDate.parse("2009-04-21")));
}