Class TenorConverter30360
- java.lang.Object
-
- com.activeviam.risk.core.dates.impl.TenorConverter30360
-
- All Implemented Interfaces:
ITenorConverter
public class TenorConverter30360 extends Object implements ITenorConverter
Legacy implementation ofITenorConverter
. When adding tenors to dates, assumes that months are 30 days and years are 360 days.
-
-
Field Summary
Fields Modifier and Type Field Description protected DateTimeFormatter
formatter
static int
MONTH
static int
WEEK
static int
YEAR
protected Pattern
YEAR_MONTH
-
Constructor Summary
Constructors Constructor Description TenorConverter30360(String tenorAndMaturityDefaultValue)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
calculateNbDays(LocalDate asOfDate, String tenor)
Transforms a tenor into a number of days.LocalDate
convert(com.qfs.store.IDatastoreVersion datastore, LocalDate asOfDate, BucketType bucketType, String tenorSet, String tenor, IBusinessDayConvention businessDayConvention, IBusinessDayCalendar calendar)
Given an as-of-date and a String representation of a tenor, returns the LocalDate representation of the tenor (after application of business day convention).LocalDate
convert(LocalDate asOfDate, String tenor, IBusinessDayConvention businessDayConvention, IBusinessDayCalendar calendar)
Implementation ofITenorConverter.convert(LocalDate, String, IBusinessDayConvention, IBusinessDayCalendar)
which first converts the tenor into a number of days usingcalculateNbDays(LocalDate, String)
.protected YearMonth
tryParseAsDaysBetween(String tenorOrDate)
try converting tenorOrDate directly to a YearMonth
-
-
-
Field Detail
-
WEEK
public static int WEEK
-
MONTH
public static int MONTH
-
YEAR
public static int YEAR
-
YEAR_MONTH
protected final Pattern YEAR_MONTH
-
formatter
protected final DateTimeFormatter formatter
-
-
Constructor Detail
-
TenorConverter30360
public TenorConverter30360(String tenorAndMaturityDefaultValue)
-
-
Method Detail
-
convert
public LocalDate convert(com.qfs.store.IDatastoreVersion datastore, LocalDate asOfDate, BucketType bucketType, String tenorSet, String tenor, IBusinessDayConvention businessDayConvention, IBusinessDayCalendar calendar) throws ParseException
Description copied from interface:ITenorConverter
Given an as-of-date and a String representation of a tenor, returns the LocalDate representation of the tenor (after application of business day convention).- Specified by:
convert
in interfaceITenorConverter
- Parameters:
datastore
- The datastore version.asOfDate
- The initial as-of-date.bucketType
- The tenor store.tenorSet
- The tenor set.tenor
- The String representation of a tenor.businessDayConvention
- The business day convention to use.calendar
- the business day calendar.- Returns:
- The LocalDate represented by the input tenor or date, given the as-of-date.
- Throws:
ParseException
- the tenor is not recognized.
-
convert
public LocalDate convert(LocalDate asOfDate, String tenor, IBusinessDayConvention businessDayConvention, IBusinessDayCalendar calendar) throws ParseException
Implementation ofITenorConverter.convert(LocalDate, String, IBusinessDayConvention, IBusinessDayCalendar)
which first converts the tenor into a number of days usingcalculateNbDays(LocalDate, String)
. No business day convention is applied.- Specified by:
convert
in interfaceITenorConverter
- Parameters:
asOfDate
- The initial as-of-date.tenor
- The String representation of a tenor.businessDayConvention
- The business day convention to use.calendar
- the business day calendar.- Returns:
- The LocalDate represented by the input tenor or date, given the as-of-date.
- Throws:
ParseException
- the tenor is not recognized.
-
calculateNbDays
protected int calculateNbDays(LocalDate asOfDate, String tenor)
Transforms a tenor into a number of days. Uses the 7/30/360 convention for number of dates in W/M/Y.- Parameters:
asOfDate
- the as of date used as a referencetenor
- The given tenor.- Returns:
- The numbers of days represented by the tenor.
-
tryParseAsDaysBetween
protected YearMonth tryParseAsDaysBetween(String tenorOrDate)
try converting tenorOrDate directly to a YearMonth- Parameters:
tenorOrDate
- the String representation of a tenor or date or number of days.- Returns:
- the YearMonth of days if applicable, or null if tenorOrDate could not be parsed as a yearMonth
-
-