|
From: <be...@us...> - 2006-09-05 11:17:14
|
Revision: 109
http://svn.sourceforge.net/objectlabkit/?rev=109&view=rev
Author: benoitx
Date: 2006-09-05 04:16:39 -0700 (Tue, 05 Sep 2006)
Log Message:
-----------
Moved ExcelDateUtil.java to Common for Date and Calendar.
Provided generic tests, used in common for Date and Calendar and used in Joda for LocalDate, YearMonthDay and DateTime.
Simplified the JodaExcelDateUtil.
Cool hey?
+ some formatting.
Modified Paths:
--------------
trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/DateCalculator.java
trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/Utils.java
trunk/datecalc-common/src/test/java/net/objectlab/kit/datecalc/common/AbstractPeriodCountCalculator.java
trunk/datecalc-jdk/src/main/java/net/objectlab/kit/datecalc/jdk/CalendarPeriodCountCalculator.java
trunk/datecalc-jdk/src/main/java/net/objectlab/kit/datecalc/jdk/JdkCalendarBaseDateCalculator.java
trunk/datecalc-jdk/src/test/java/net/objectlab/kit/datecalc/jdk/DatePeriodCountCalculatorTest.java
trunk/datecalc-jdk/src/test/java/net/objectlab/kit/datecalc/jdk/IMMDateTest.java
trunk/datecalc-joda/src/main/java/net/objectlab/kit/datecalc/joda/JodaWorkingWeek.java
trunk/datecalc-joda/src/main/java/net/objectlab/kit/datecalc/joda/LocalDateCalculator.java
trunk/datecalc-joda/src/test/java/net/objectlab/kit/datecalc/joda/IMMDateTest.java
trunk/datecalc-joda/src/test/java/net/objectlab/kit/datecalc/joda/PeriodCountCalculatorTest.java
Added Paths:
-----------
trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/ExcelDateUtil.java
trunk/datecalc-common/src/test/java/net/objectlab/kit/datecalc/common/AbstractExcelDateUtilTest.java
trunk/datecalc-common/src/test/java/net/objectlab/kit/datecalc/common/CalendarExcelDateUtilTest.java
trunk/datecalc-common/src/test/java/net/objectlab/kit/datecalc/common/DateExcelDateUtilTest.java
trunk/datecalc-joda/src/main/java/net/objectlab/kit/datecalc/joda/JodaExcelDateUtil.java
trunk/datecalc-joda/src/test/java/net/objectlab/kit/datecalc/joda/DateTimeExcelDateUtilTest.java
trunk/datecalc-joda/src/test/java/net/objectlab/kit/datecalc/joda/LocalDateExcelDateUtilTest.java
trunk/datecalc-joda/src/test/java/net/objectlab/kit/datecalc/joda/YearMonthDayExcelDateUtilTest.java
Removed Paths:
-------------
trunk/datecalc-jdk/src/main/java/net/objectlab/kit/datecalc/jdk/ExcelDateUtil.java
trunk/datecalc-joda/src/main/java/net/objectlab/kit/datecalc/joda/ExcelDateUtil.java
Modified: trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/DateCalculator.java
===================================================================
--- trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/DateCalculator.java 2006-09-05 10:13:01 UTC (rev 108)
+++ trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/DateCalculator.java 2006-09-05 11:16:39 UTC (rev 109)
@@ -23,11 +23,12 @@
/**
* A DateCalculator is a lightweight container with an optional reference to a
* set of holidays, a WorkingWeek (Mon-Fri by default), a startDate and a
- * current business date. The Calculator also uses a HolidayHandler to determine what to
- * do when the calculated current Business Date falls on a weekend or holiday (non-working day).
- * The CurrentDate date is changed everytime that the moveByDays or moveByBusinessDays methods are called.
- * 'E' will be parameterized to be a Date-like class, i.e. java.util.Date or java.util.Calendar (and LocalDate
- * or YearMonthDay for Joda-time).
+ * current business date. The Calculator also uses a HolidayHandler to determine
+ * what to do when the calculated current Business Date falls on a weekend or
+ * holiday (non-working day). The CurrentDate date is changed everytime that the
+ * moveByDays or moveByBusinessDays methods are called. 'E' will be
+ * parameterized to be a Date-like class, i.e. java.util.Date or
+ * java.util.Calendar (and LocalDate or YearMonthDay for Joda-time).
*
* @author Benoit Xhenseval
* @author $LastChangedBy$
@@ -37,36 +38,42 @@
/**
* This is typically the name of the associated set of holidays.
+ *
* @return calculator name (Typically the name associated with the holiday
* set).
*/
String getName();
/**
- * Setting the start date also sets the current business date (and if this is a non-working day,
- * the current business date will be moved to the next business day acording to the HolidayHandler
- * algorithm given).
+ * Setting the start date also sets the current business date (and if this
+ * is a non-working day, the current business date will be moved to the next
+ * business day acording to the HolidayHandler algorithm given).
+ *
* @param startDate
- * the reference date for this calculator, the current business date is also
- * updated and may be moved if it falls on a non working day
- * (holiday/weekend).
+ * the reference date for this calculator, the current business
+ * date is also updated and may be moved if it falls on a non
+ * working day (holiday/weekend).
*/
void setStartDate(final E startDate);
/**
- * Gives the startDate of this calculator (immutable once set via setStartDate).
+ * Gives the startDate of this calculator (immutable once set via
+ * setStartDate).
+ *
* @return startDate the reference date for this calculator.
*/
E getStartDate();
/**
* Gives the current business date held by the calculator.
+ *
* @return a date.
*/
E getCurrentBusinessDate();
/**
* Is the given date falling on a weekend, according to the WorkingWeek.
+ *
* @return true if the date falls on a weekend.
*/
boolean isWeekend(final E date);
@@ -74,6 +81,7 @@
/**
* Is the given date a non working day, i.e. either a "weekend" or a
* holiday?
+ *
* @return true if the given date is non-working.
*/
boolean isNonWorkingDay(final E date);
@@ -81,15 +89,16 @@
/**
* Is the current business day a non-working day, this is useful if the
* calculator does not have any algorithm to change the date when it falls
- * on a non-working day. This method can then be used to show a warning to the
- * user.
+ * on a non-working day. This method can then be used to show a warning to
+ * the user.
+ *
* @return true if the current date is either a weekend or a holiday.
*/
boolean isCurrentDateNonWorking();
/**
- * This is typically used at the construction of a DateCalculator to give
- * a reference to a set of holidays.
+ * This is typically used at the construction of a DateCalculator to give a
+ * reference to a set of holidays.
*
* @param holidays
* the holiday (if null, an empty set will be put in place)
@@ -98,6 +107,7 @@
/**
* Gives a immutable copy of the set of registered holidays.
+ *
* @return an immutable copy of the holiday set.
*/
Set<E> getNonWorkingDays();
@@ -106,13 +116,14 @@
* Allows user to define what their Working Week should be (default is
* Mon-Fri).
*
- * @param week an immutable definition of a week.
+ * @param week
+ * an immutable definition of a week.
*/
void setWorkingWeek(final WorkingWeek week);
/**
- * Gives a current business date, it may be moved acording to the HolidayHandler algorithm
- * if it falls on a non-working day.
+ * Gives a current business date, it may be moved acording to the
+ * HolidayHandler algorithm if it falls on a non-working day.
*
* @param date
* @return new current business date if moved.
@@ -120,16 +131,18 @@
E setCurrentBusinessDate(final E date);
/**
- * Gives the name of the holiday handler algorithm, see HolidayHandlerType for some standard values.
+ * Gives the name of the holiday handler algorithm, see HolidayHandlerType
+ * for some standard values.
+ *
* @return the holiday handler type, can be null
*/
String getHolidayHandlerType();
/**
- * This changes the current business date held in the calculator, it moves the
- * new current business date by the number of days and, if it falls on a weekend
- * or holiday, moves it further according to the HolidayHandler given in this
- * DateCalculator.
+ * This changes the current business date held in the calculator, it moves
+ * the new current business date by the number of days and, if it falls on a
+ * weekend or holiday, moves it further according to the HolidayHandler
+ * given in this DateCalculator.
*
* @param days
* number of days (can be <0 or >0)
@@ -139,16 +152,20 @@
DateCalculator<E> moveByDays(final int days);
/**
- * This changes the current business date held in the calculator, it moves the
- * current date by a number of business days, this means that if a
- * date is either a 'weekend' or holiday along the way, it will be skipped acording to the
- * holiday handler and not count towards the number of days to move.
+ * This changes the current business date held in the calculator, it moves
+ * the current date by a number of business days, this means that if a date
+ * is either a 'weekend' or holiday along the way, it will be skipped
+ * acording to the holiday handler and not count towards the number of days
+ * to move.
*
- * @param businessDays (can be <0 or >0)
+ * @param businessDays
+ * (can be <0 or >0)
* @return the current businessCalendar (so one can do
* calendar.moveByBusinessDays(2).getCurrentBusinessDate();)
- * @exception IllegalArgumentException if the HolidayHandlerType is (MODIFIED_PRECEEDING or BACKWARD) and businessDays > 0
- * or (MODIFIED_FOLLOWING or FORWARD) and businessDays < 0
+ * @exception IllegalArgumentException
+ * if the HolidayHandlerType is (MODIFIED_PRECEEDING or
+ * BACKWARD) and businessDays > 0 or (MODIFIED_FOLLOWING or
+ * FORWARD) and businessDays < 0
*/
DateCalculator<E> moveByBusinessDays(final int businessDays);
@@ -178,23 +195,26 @@
DateCalculator<E> moveByTenor(final Tenor tenor);
/**
- * Checks if a given date is an official IMM Date (3rd Wednesdays of March/June/Sept/Dec.
+ * Checks if a given date is an official IMM Date (3rd Wednesdays of
+ * March/June/Sept/Dec.
+ *
* @param date
* @return true if that date is an IMM date.
*/
boolean isIMMDate(E date);
/**
- * Starting from the current business date, it will return the next IMM Date, even if the
- * current business date is an IMM date (same as calling getNextIMMDate(IMMPeriod.QUARTERLY)).
+ * Starting from the current business date, it will return the next IMM
+ * Date, even if the current business date is an IMM date (same as calling
+ * getNextIMMDate(IMMPeriod.QUARTERLY)).
*
* @return the next IMMDate based on current business date.
*/
E getNextIMMDate();
/**
- * Starting from the current business date, it will return the next IMM Date based on the IMMPeriod,
- * even if the current business date is an IMM date.
+ * Starting from the current business date, it will return the next IMM Date
+ * based on the IMMPeriod, even if the current business date is an IMM date.
*
* @param period
* specify when the "next" IMM is, if quarterly then it is the
@@ -204,16 +224,17 @@
E getNextIMMDate(IMMPeriod period);
/**
- * Starting from the current business date, it will return the previous IMM Date, even if the
- * current business date is an IMM date.
+ * Starting from the current business date, it will return the previous IMM
+ * Date, even if the current business date is an IMM date.
*
* @return the previous IMMDate based on current date.
*/
E getPreviousIMMDate();
/**
- * Starting from the current business date, it will return the previous IMM Date based on the IMMPeriod,
- * even if the current business date is an IMM date.
+ * Starting from the current business date, it will return the previous IMM
+ * Date based on the IMMPeriod, even if the current business date is an IMM
+ * date.
*
* @param period
* specify when the "previous" IMM is, if quarterly then it is
Added: trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/ExcelDateUtil.java
===================================================================
--- trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/ExcelDateUtil.java (rev 0)
+++ trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/ExcelDateUtil.java 2006-09-05 11:16:39 UTC (rev 109)
@@ -0,0 +1,154 @@
+/*
+ * $Id: ExcelDateUtil.java 99 2006-09-04 20:30:25Z marchy $
+ *
+ * Copyright 2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package net.objectlab.kit.datecalc.common;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+/**
+ * Convert Excel Date to LocalDate, YearMonthDay or DateTime.
+ *
+ * @author Benoit Xhenseval
+ * @author $LastChangedBy: marchy $
+ * @version $Revision: 99 $ $Date: 2006-09-04 21:30:25 +0100 (Mon, 04 Sep 2006) $
+ *
+ */
+public class ExcelDateUtil {
+ private static final double HALF_MILLISEC = 0.5;
+
+ private static final int EXCEL_FUDGE_19000229 = 61;
+
+ private static final int EXCEL_WINDOWING_1904 = 1904;
+
+ private static final int EXCEL_BASE_YEAR = 1900;
+
+ private static final long DAY_MILLISECONDS = 24 * 60 * 60 * 1000;
+
+ private ExcelDateUtil() {
+ }
+
+ /**
+ * Given an Excel date with either 1900 or 1904 date windowing, converts it
+ * to a java.util.Date.
+ *
+ * @param date
+ * The Excel date.
+ * @param use1904windowing
+ * true if date uses 1904 windowing, or false if using 1900 date
+ * windowing.
+ * @return Java representation of the date without any time.
+ *
+ * @see java.util.TimeZone
+ */
+ public static Calendar getJavaCalendar(final double date, final boolean use1904windowing) {
+ final Calendar cal = Calendar.getInstance();
+ final Date javaDate = getJavaDate(date, use1904windowing);
+ if (javaDate == null) {
+ return null;
+ }
+ cal.setTime(javaDate);
+ cal.setTimeZone(TimeZone.getTimeZone("UTC"));
+ cal.set(Calendar.HOUR, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ return cal;
+ }
+
+ /**
+ * Given an Excel date with either 1900 or 1904 date windowing, converts it
+ * to a java.util.Date.
+ *
+ * @param date
+ * The Excel date.
+ * @param use1904windowing
+ * true if date uses 1904 windowing, or false if using 1900 date
+ * windowing.
+ * @return Java representation of the date without any time.
+ *
+ * @see java.util.TimeZone
+ */
+ public static Date getJavaDateOnly(final double date, final boolean use1904windowing) {
+ final Calendar javaCalendar = getJavaCalendar(date, use1904windowing);
+ if (javaCalendar == null) {
+ return null;
+ }
+ return javaCalendar.getTime();
+ }
+
+ /**
+ * Given an Excel date with either 1900 or 1904 date windowing, converts it
+ * to a java.util.Date.
+ *
+ * NOTE: If the default <code>TimeZone</code> in Java uses Daylight Saving
+ * Time then the conversion back to an Excel date may not give the same
+ * value, that is the comparison <CODE>excelDate ==
+ * getExcelDate(getJavaDate(excelDate,false))</CODE> is not always true.
+ * For example if default timezone is <code>Europe/Copenhagen</code>, on
+ * 2004-03-28 the minute after 01:59 CET is 03:00 CEST, if the excel date
+ * represents a time between 02:00 and 03:00 then it is converted to past
+ * 03:00 summer time
+ *
+ * @param date
+ * The Excel date.
+ * @param use1904windowing
+ * true if date uses 1904 windowing, or false if using 1900 date
+ * windowing.
+ * @return Java representation of the date, or null if date is not a valid
+ * Excel date
+ * @see java.util.TimeZone
+ */
+ public static Date getJavaDate(final double date, final boolean use1904windowing) {
+ if (isValidExcelDate(date)) {
+ int startYear = EXCEL_BASE_YEAR;
+ int dayAdjust = -1; // Excel thinks 2/29/1900 is a valid date, which
+ // it isn't
+ final int wholeDays = (int) Math.floor(date);
+ if (use1904windowing) {
+ startYear = EXCEL_WINDOWING_1904;
+ dayAdjust = 1; // 1904 date windowing uses 1/2/1904 as the
+ // first day
+ } else if (wholeDays < EXCEL_FUDGE_19000229) {
+ // Date is prior to 3/1/1900, so adjust because Excel thinks
+ // 2/29/1900 exists
+ // If Excel date == 2/29/1900, will become 3/1/1900 in Java
+ // representation
+ dayAdjust = 0;
+ }
+ final GregorianCalendar calendar = new GregorianCalendar(startYear, 0, wholeDays + dayAdjust);
+ final int millisecondsInDay = (int) ((date - Math.floor(date)) * DAY_MILLISECONDS + HALF_MILLISEC);
+ calendar.set(Calendar.MILLISECOND, millisecondsInDay);
+ return calendar.getTime();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Given a double, checks if it is a valid Excel date.
+ *
+ * @return true if valid
+ * @param value
+ * the double value
+ */
+ public static boolean isValidExcelDate(final double value) {
+ return (value > -Double.MIN_VALUE);
+ }
+}
Modified: trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/Utils.java
===================================================================
--- trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/Utils.java 2006-09-05 10:13:01 UTC (rev 108)
+++ trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/Utils.java 2006-09-05 11:16:39 UTC (rev 109)
@@ -60,6 +60,16 @@
}
}
+ public static Calendar createCalendar(final String str) throws IllegalArgumentException {
+ try {
+ final Date date = SDF.parse(str);
+ final Calendar cal = getCal(date);
+ return cal;
+ } catch (final ParseException e) {
+ throw new IllegalArgumentException("\"" + str + "\"" + " is an invalid date, the pattern is : " + DATE_PATTERN);
+ }
+ }
+
public static Set<Calendar> toCalendarSet(final Set<Date> dates) {
final Set<Calendar> calendars = new HashSet<Calendar>();
for (final Date date : dates) {
Added: trunk/datecalc-common/src/test/java/net/objectlab/kit/datecalc/common/AbstractExcelDateUtilTest.java
===================================================================
--- trunk/datecalc-common/src/test/java/net/objectlab/kit/datecalc/common/AbstractExcelDateUtilTest.java (rev 0)
+++ trunk/datecalc-common/src/test/java/net/objectlab/kit/datecalc/common/AbstractExcelDateUtilTest.java 2006-09-05 11:16:39 UTC (rev 109)
@@ -0,0 +1,28 @@
+package net.objectlab.kit.datecalc.common;
+
+import junit.framework.TestCase;
+
+public abstract class AbstractExcelDateUtilTest<E> extends TestCase {
+ protected abstract E createDate(final String str);
+
+ protected abstract E createDateFromExcel(double excelDate);
+
+ public void testExcelDate() {
+ checkDate(createDate("1899-12-31"), 0);
+ checkDate(createDate("1900-01-01"), 1.0);
+ checkDate(createDate("1900-03-01"), 61.0);
+ checkDate(createDate("1968-06-11"), 25000.0);
+ checkDate(createDate("1978-05-31"), 28641.00);
+ checkDate(createDate("1999-12-31"), 36525.00);
+ checkDate(createDate("2000-01-01"), 36526.00);
+ checkDate(createDate("2000-01-01"), 36526.00);
+ checkDate(createDate("2000-02-28"), 36584.00);
+ checkDate(createDate("2000-02-29"), 36585.00);
+ checkDate(createDate("2000-03-01"), 36586.00);
+ checkDate(null, -1.0);
+ }
+
+ private void checkDate(final E date, final double excelDate) {
+ assertEquals("excel:" + excelDate, date, createDateFromExcel(excelDate));
+ }
+}
Modified: trunk/datecalc-common/src/test/java/net/objectlab/kit/datecalc/common/AbstractPeriodCountCalculator.java
===================================================================
--- trunk/datecalc-common/src/test/java/net/objectlab/kit/datecalc/common/AbstractPeriodCountCalculator.java 2006-09-05 10:13:01 UTC (rev 108)
+++ trunk/datecalc-common/src/test/java/net/objectlab/kit/datecalc/common/AbstractPeriodCountCalculator.java 2006-09-05 11:16:39 UTC (rev 109)
@@ -2,315 +2,316 @@
import java.math.BigDecimal;
-import net.objectlab.kit.datecalc.common.PeriodCountBasis;
-import net.objectlab.kit.datecalc.common.PeriodCountCalculator;
-
import junit.framework.Assert;
import junit.framework.TestCase;
public abstract class AbstractPeriodCountCalculator<E> extends TestCase {
private static final String[][] ACT_365 = {
- // name start end period dayDiff yearDiff
- { "0D", "2006-08-08", "2006-08-08", "ACT_365", "0", "0.00" },
- { "1D", "2006-08-08", "2006-08-09", "ACT_365", "1", "0.002740" },
- { "1W", "2006-08-08", "2006-08-15", "ACT_365", "7", "0.019178" },
- { "1M", "2006-08-08", "2006-09-08", "ACT_365", "31", "0.084932" },
- { "3M", "2006-08-08", "2006-11-08", "ACT_365", "92", "0.252055" },
- { "6M", "2006-08-08", "2007-02-08", "ACT_365", "184", "0.504110" },
- { "9M", "2006-08-08", "2007-05-08", "ACT_365", "273", "0.747945" },
- { "1Y", "2006-08-08", "2007-08-08", "ACT_365", "365", "1.000000" },
- { "2Y", "2006-08-08", "2008-08-08", "ACT_365", "731", "2.002740" },
- { "3Y", "2006-08-08", "2009-08-10", "ACT_365", "1098", "3.008219" },
- { "4Y", "2006-08-08", "2010-08-09", "ACT_365", "1462", "4.005479" },
- { "5Y", "2006-08-08", "2011-08-08", "ACT_365", "1826", "5.002740" },
- { "7Y", "2006-08-08", "2013-08-08", "ACT_365", "2557", "7.005479" },
- { "10Y", "2006-08-08", "2016-08-08", "ACT_365", "3653", "10.008219" },
- { "15Y", "2006-08-08", "2021-08-09", "ACT_365", "5480", "15.013699" },
- { "20Y", "2006-08-08", "2026-08-10", "ACT_365", "7307", "20.019178" },
- { "30Y", "2006-08-08", "2036-08-08", "ACT_365", "10958", "30.021918" },
- // leap year - funny date...
- { "0D", "2008-02-29", "2008-02-29", "ACT_365", "0", "0.00" },
- { "1D", "2008-02-29", "2008-03-03", "ACT_365", "3", "0.008219" },
- { "1W", "2008-02-29", "2008-03-07", "ACT_365", "7", "0.019178" },
- { "1M", "2008-02-29", "2008-03-31", "ACT_365", "31", "0.084932" },
- { "3M", "2008-02-29", "2008-05-29", "ACT_365", "90", "0.246575" },
- { "6M", "2008-02-29", "2008-08-29", "ACT_365", "182", "0.498630" },
- { "9M", "2008-02-29", "2008-11-28", "ACT_365", "273", "0.747945" },
- { "1Y", "2008-02-29", "2009-02-27", "ACT_365", "364", "0.997260" },
- { "2Y", "2008-02-29", "2010-02-26", "ACT_365", "728", "1.994521" },
- { "3Y", "2008-02-29", "2011-02-28", "ACT_365", "1095", "3.000000" },
- { "4Y", "2008-02-29", "2012-02-29", "ACT_365", "1461", "4.002740" },
- { "5Y", "2008-02-29", "2013-02-28", "ACT_365", "1826", "5.002740" },
- { "7Y", "2008-02-29", "2015-02-27", "ACT_365", "2555", "7.000000" },
- { "10Y", "2008-02-29", "2018-02-28", "ACT_365", "3652", "10.005479" },
- { "15Y", "2008-02-29", "2023-02-28", "ACT_365", "5478", "15.008219" },
- { "20Y", "2008-02-29", "2028-02-29", "ACT_365", "7305", "20.013699" },
- { "30Y", "2008-02-29", "2038-02-26", "ACT_365", "10955", "30.013699" },
- // start date end of month...
- { "0D", "1998-12-31", "1998-12-31", "ACT_365", "0", "0.00" },
- { "1D", "1998-12-31", "1999-01-01", "ACT_365", "1", "0.002740" },
- { "1W", "1998-12-31", "1999-01-07", "ACT_365", "7", "0.019178" },
- { "1M", "1998-12-31", "1999-01-29", "ACT_365", "29", "0.079452" },
- { "3M", "1998-12-31", "1999-03-31", "ACT_365", "90", "0.246575" },
- { "6M", "1998-12-31", "1999-06-30", "ACT_365", "181", "0.495890" },
- { "9M", "1998-12-31", "1999-09-30", "ACT_365", "273", "0.747945" },
- { "1Y", "1998-12-31", "1999-12-31", "ACT_365", "365", "1.000000" },
- { "2Y", "1998-12-31", "2000-12-29", "ACT_365", "729", "1.997260" },
- { "3Y", "1998-12-31", "2001-12-31", "ACT_365", "1096", "3.002740" },
- { "4Y", "1998-12-31", "2002-12-31", "ACT_365", "1461", "4.002740" },
- { "5Y", "1998-12-31", "2003-12-31", "ACT_365", "1826", "5.002740" },
- { "7Y", "1998-12-31", "2005-12-30", "ACT_365", "2556", "7.002740" },
- { "10Y", "1998-12-31", "2008-12-31", "ACT_365", "3653", "10.008219" },
- { "15Y", "1998-12-31", "2013-12-31", "ACT_365", "5479", "15.010959" },
- { "20Y", "1998-12-31", "2018-12-31", "ACT_365", "7305", "20.013699" },
- { "30Y", "1998-12-31", "2028-12-29", "ACT_365", "10956", "30.016438" }
- // end of set
- };
+ // name start end period dayDiff yearDiff
+ { "0D", "2006-08-08", "2006-08-08", "ACT_365", "0", "0.00" },
+ { "1D", "2006-08-08", "2006-08-09", "ACT_365", "1", "0.002740" },
+ { "1W", "2006-08-08", "2006-08-15", "ACT_365", "7", "0.019178" },
+ { "1M", "2006-08-08", "2006-09-08", "ACT_365", "31", "0.084932" },
+ { "3M", "2006-08-08", "2006-11-08", "ACT_365", "92", "0.252055" },
+ { "6M", "2006-08-08", "2007-02-08", "ACT_365", "184", "0.504110" },
+ { "9M", "2006-08-08", "2007-05-08", "ACT_365", "273", "0.747945" },
+ { "1Y", "2006-08-08", "2007-08-08", "ACT_365", "365", "1.000000" },
+ { "2Y", "2006-08-08", "2008-08-08", "ACT_365", "731", "2.002740" },
+ { "3Y", "2006-08-08", "2009-08-10", "ACT_365", "1098", "3.008219" },
+ { "4Y", "2006-08-08", "2010-08-09", "ACT_365", "1462", "4.005479" },
+ { "5Y", "2006-08-08", "2011-08-08", "ACT_365", "1826", "5.002740" },
+ { "7Y", "2006-08-08", "2013-08-08", "ACT_365", "2557", "7.005479" },
+ { "10Y", "2006-08-08", "2016-08-08", "ACT_365", "3653", "10.008219" },
+ { "15Y", "2006-08-08", "2021-08-09", "ACT_365", "5480", "15.013699" },
+ { "20Y", "2006-08-08", "2026-08-10", "ACT_365", "7307", "20.019178" },
+ { "30Y", "2006-08-08", "2036-08-08", "ACT_365", "10958", "30.021918" },
+ // leap year - funny date...
+ { "0D", "2008-02-29", "2008-02-29", "ACT_365", "0", "0.00" },
+ { "1D", "2008-02-29", "2008-03-03", "ACT_365", "3", "0.008219" },
+ { "1W", "2008-02-29", "2008-03-07", "ACT_365", "7", "0.019178" },
+ { "1M", "2008-02-29", "2008-03-31", "ACT_365", "31", "0.084932" },
+ { "3M", "2008-02-29", "2008-05-29", "ACT_365", "90", "0.246575" },
+ { "6M", "2008-02-29", "2008-08-29", "ACT_365", "182", "0.498630" },
+ { "9M", "2008-02-29", "2008-11-28", "ACT_365", "273", "0.747945" },
+ { "1Y", "2008-02-29", "2009-02-27", "ACT_365", "364", "0.997260" },
+ { "2Y", "2008-02-29", "2010-02-26", "ACT_365", "728", "1.994521" },
+ { "3Y", "2008-02-29", "2011-02-28", "ACT_365", "1095", "3.000000" },
+ { "4Y", "2008-02-29", "2012-02-29", "ACT_365", "1461", "4.002740" },
+ { "5Y", "2008-02-29", "2013-02-28", "ACT_365", "1826", "5.002740" },
+ { "7Y", "2008-02-29", "2015-02-27", "ACT_365", "2555", "7.000000" },
+ { "10Y", "2008-02-29", "2018-02-28", "ACT_365", "3652", "10.005479" },
+ { "15Y", "2008-02-29", "2023-02-28", "ACT_365", "5478", "15.008219" },
+ { "20Y", "2008-02-29", "2028-02-29", "ACT_365", "7305", "20.013699" },
+ { "30Y", "2008-02-29", "2038-02-26", "ACT_365", "10955", "30.013699" },
+ // start date end of month...
+ { "0D", "1998-12-31", "1998-12-31", "ACT_365", "0", "0.00" },
+ { "1D", "1998-12-31", "1999-01-01", "ACT_365", "1", "0.002740" },
+ { "1W", "1998-12-31", "1999-01-07", "ACT_365", "7", "0.019178" },
+ { "1M", "1998-12-31", "1999-01-29", "ACT_365", "29", "0.079452" },
+ { "3M", "1998-12-31", "1999-03-31", "ACT_365", "90", "0.246575" },
+ { "6M", "1998-12-31", "1999-06-30", "ACT_365", "181", "0.495890" },
+ { "9M", "1998-12-31", "1999-09-30", "ACT_365", "273", "0.747945" },
+ { "1Y", "1998-12-31", "1999-12-31", "ACT_365", "365", "1.000000" },
+ { "2Y", "1998-12-31", "2000-12-29", "ACT_365", "729", "1.997260" },
+ { "3Y", "1998-12-31", "2001-12-31", "ACT_365", "1096", "3.002740" },
+ { "4Y", "1998-12-31", "2002-12-31", "ACT_365", "1461", "4.002740" },
+ { "5Y", "1998-12-31", "2003-12-31", "ACT_365", "1826", "5.002740" },
+ { "7Y", "1998-12-31", "2005-12-30", "ACT_365", "2556", "7.002740" },
+ { "10Y", "1998-12-31", "2008-12-31", "ACT_365", "3653", "10.008219" },
+ { "15Y", "1998-12-31", "2013-12-31", "ACT_365", "5479", "15.010959" },
+ { "20Y", "1998-12-31", "2018-12-31", "ACT_365", "7305", "20.013699" },
+ { "30Y", "1998-12-31", "2028-12-29", "ACT_365", "10956", "30.016438" }
+ // end of set
+ };
+
private static final String[][] ACT_360 = {
- // name start end period dayDiff yearDiff
- { "0D", "2006-08-08", "2006-08-08", "ACT_360", "0", "0.00" },
- { "1D", "2006-08-08", "2006-08-09", "ACT_360", "1", "0.002778" },
- { "1W", "2006-08-08", "2006-08-15", "ACT_360", "7", "0.019444" },
- { "1M", "2006-08-08", "2006-09-08", "ACT_360", "31", "0.086111" },
- { "3M", "2006-08-08", "2006-11-08", "ACT_360", "92", "0.255556" },
- { "6M", "2006-08-08", "2007-02-08", "ACT_360", "184", "0.511111" },
- { "9M", "2006-08-08", "2007-05-08", "ACT_360", "273", "0.758333" },
- { "1Y", "2006-08-08", "2007-08-08", "ACT_360", "365", "1.013889" },
- { "2Y", "2006-08-08", "2008-08-08", "ACT_360", "731", "2.030556" },
- { "3Y", "2006-08-08", "2009-08-10", "ACT_360", "1098", "3.050000" },
- { "4Y", "2006-08-08", "2010-08-09", "ACT_360", "1462", "4.061111" },
- { "5Y", "2006-08-08", "2011-08-08", "ACT_360", "1826", "5.072222" },
- { "7Y", "2006-08-08", "2013-08-08", "ACT_360", "2557", "7.102778" },
- { "10Y", "2006-08-08", "2016-08-08", "ACT_360", "3653", "10.147222" },
- { "15Y", "2006-08-08", "2021-08-09", "ACT_360", "5480", "15.222222" },
- { "20Y", "2006-08-08", "2026-08-10", "ACT_360", "7307", "20.297222" },
- { "30Y", "2006-08-08", "2036-08-08", "ACT_360", "10958", "30.438889" },
- // leap year - funny date...
- { "0D", "2008-02-29", "2008-02-29", "ACT_360", "0", "0.00" },
- { "1D", "2008-02-29", "2008-03-03", "ACT_360", "3", "0.008333" },
- { "1W", "2008-02-29", "2008-03-07", "ACT_360", "7", "0.019444" },
- { "1M", "2008-02-29", "2008-03-31", "ACT_360", "31", "0.086111" },
- { "3M", "2008-02-29", "2008-05-29", "ACT_360", "90", "0.250000" },
- { "6M", "2008-02-29", "2008-08-29", "ACT_360", "182", "0.505556" },
- { "9M", "2008-02-29", "2008-11-28", "ACT_360", "273", "0.758333" },
- { "1Y", "2008-02-29", "2009-02-27", "ACT_360", "364", "1.011111" },
- { "2Y", "2008-02-29", "2010-02-26", "ACT_360", "728", "2.022222" },
- { "3Y", "2008-02-29", "2011-02-28", "ACT_360", "1095", "3.041667" },
- { "4Y", "2008-02-29", "2012-02-29", "ACT_360", "1461", "4.058333" },
- { "5Y", "2008-02-29", "2013-02-28", "ACT_360", "1826", "5.072222" },
- { "7Y", "2008-02-29", "2015-02-27", "ACT_360", "2555", "7.097222" },
- { "10Y", "2008-02-29", "2018-02-28", "ACT_360", "3652", "10.144444" },
- { "15Y", "2008-02-29", "2023-02-28", "ACT_360", "5478", "15.216667" },
- { "20Y", "2008-02-29", "2028-02-29", "ACT_360", "7305", "20.291667" },
- { "30Y", "2008-02-29", "2038-02-26", "ACT_360", "10955", "30.430556" },
- // start date end of month...
- { "0D", "1998-12-31", "1998-12-31", "ACT_360", "0", "0.00" },
- { "1D", "1998-12-31", "1999-01-01", "ACT_360", "1", "0.002778" },
- { "1W", "1998-12-31", "1999-01-07", "ACT_360", "7", "0.019444" },
- { "1M", "1998-12-31", "1999-01-29", "ACT_360", "29", "0.080556" },
- { "3M", "1998-12-31", "1999-03-31", "ACT_360", "90", "0.250000" },
- { "6M", "1998-12-31", "1999-06-30", "ACT_360", "181", "0.502778" },
- { "9M", "1998-12-31", "1999-09-30", "ACT_360", "273", "0.758333" },
- { "1Y", "1998-12-31", "1999-12-31", "ACT_360", "365", "1.013889" },
- { "2Y", "1998-12-31", "2000-12-29", "ACT_360", "729", "2.025000" },
- { "3Y", "1998-12-31", "2001-12-31", "ACT_360", "1096", "3.044444" },
- { "4Y", "1998-12-31", "2002-12-31", "ACT_360", "1461", "4.058333" },
- { "5Y", "1998-12-31", "2003-12-31", "ACT_360", "1826", "5.072222" },
- { "7Y", "1998-12-31", "2005-12-30", "ACT_360", "2556", "7.100000" },
- { "10Y", "1998-12-31", "2008-12-31", "ACT_360", "3653", "10.147222" },
- { "15Y", "1998-12-31", "2013-12-31", "ACT_360", "5479", "15.219444" },
- { "20Y", "1998-12-31", "2018-12-31", "ACT_360", "7305", "20.291667" },
- { "30Y", "1998-12-31", "2028-12-29", "ACT_360", "10956", "30.433333" }
- // end of set
- };
+ // name start end period dayDiff yearDiff
+ { "0D", "2006-08-08", "2006-08-08", "ACT_360", "0", "0.00" },
+ { "1D", "2006-08-08", "2006-08-09", "ACT_360", "1", "0.002778" },
+ { "1W", "2006-08-08", "2006-08-15", "ACT_360", "7", "0.019444" },
+ { "1M", "2006-08-08", "2006-09-08", "ACT_360", "31", "0.086111" },
+ { "3M", "2006-08-08", "2006-11-08", "ACT_360", "92", "0.255556" },
+ { "6M", "2006-08-08", "2007-02-08", "ACT_360", "184", "0.511111" },
+ { "9M", "2006-08-08", "2007-05-08", "ACT_360", "273", "0.758333" },
+ { "1Y", "2006-08-08", "2007-08-08", "ACT_360", "365", "1.013889" },
+ { "2Y", "2006-08-08", "2008-08-08", "ACT_360", "731", "2.030556" },
+ { "3Y", "2006-08-08", "2009-08-10", "ACT_360", "1098", "3.050000" },
+ { "4Y", "2006-08-08", "2010-08-09", "ACT_360", "1462", "4.061111" },
+ { "5Y", "2006-08-08", "2011-08-08", "ACT_360", "1826", "5.072222" },
+ { "7Y", "2006-08-08", "2013-08-08", "ACT_360", "2557", "7.102778" },
+ { "10Y", "2006-08-08", "2016-08-08", "ACT_360", "3653", "10.147222" },
+ { "15Y", "2006-08-08", "2021-08-09", "ACT_360", "5480", "15.222222" },
+ { "20Y", "2006-08-08", "2026-08-10", "ACT_360", "7307", "20.297222" },
+ { "30Y", "2006-08-08", "2036-08-08", "ACT_360", "10958", "30.438889" },
+ // leap year - funny date...
+ { "0D", "2008-02-29", "2008-02-29", "ACT_360", "0", "0.00" },
+ { "1D", "2008-02-29", "2008-03-03", "ACT_360", "3", "0.008333" },
+ { "1W", "2008-02-29", "2008-03-07", "ACT_360", "7", "0.019444" },
+ { "1M", "2008-02-29", "2008-03-31", "ACT_360", "31", "0.086111" },
+ { "3M", "2008-02-29", "2008-05-29", "ACT_360", "90", "0.250000" },
+ { "6M", "2008-02-29", "2008-08-29", "ACT_360", "182", "0.505556" },
+ { "9M", "2008-02-29", "2008-11-28", "ACT_360", "273", "0.758333" },
+ { "1Y", "2008-02-29", "2009-02-27", "ACT_360", "364", "1.011111" },
+ { "2Y", "2008-02-29", "2010-02-26", "ACT_360", "728", "2.022222" },
+ { "3Y", "2008-02-29", "2011-02-28", "ACT_360", "1095", "3.041667" },
+ { "4Y", "2008-02-29", "2012-02-29", "ACT_360", "1461", "4.058333" },
+ { "5Y", "2008-02-29", "2013-02-28", "ACT_360", "1826", "5.072222" },
+ { "7Y", "2008-02-29", "2015-02-27", "ACT_360", "2555", "7.097222" },
+ { "10Y", "2008-02-29", "2018-02-28", "ACT_360", "3652", "10.144444" },
+ { "15Y", "2008-02-29", "2023-02-28", "ACT_360", "5478", "15.216667" },
+ { "20Y", "2008-02-29", "2028-02-29", "ACT_360", "7305", "20.291667" },
+ { "30Y", "2008-02-29", "2038-02-26", "ACT_360", "10955", "30.430556" },
+ // start date end of month...
+ { "0D", "1998-12-31", "1998-12-31", "ACT_360", "0", "0.00" },
+ { "1D", "1998-12-31", "1999-01-01", "ACT_360", "1", "0.002778" },
+ { "1W", "1998-12-31", "1999-01-07", "ACT_360", "7", "0.019444" },
+ { "1M", "1998-12-31", "1999-01-29", "ACT_360", "29", "0.080556" },
+ { "3M", "1998-12-31", "1999-03-31", "ACT_360", "90", "0.250000" },
+ { "6M", "1998-12-31", "1999-06-30", "ACT_360", "181", "0.502778" },
+ { "9M", "1998-12-31", "1999-09-30", "ACT_360", "273", "0.758333" },
+ { "1Y", "1998-12-31", "1999-12-31", "ACT_360", "365", "1.013889" },
+ { "2Y", "1998-12-31", "2000-12-29", "ACT_360", "729", "2.025000" },
+ { "3Y", "1998-12-31", "2001-12-31", "ACT_360", "1096", "3.044444" },
+ { "4Y", "1998-12-31", "2002-12-31", "ACT_360", "1461", "4.058333" },
+ { "5Y", "1998-12-31", "2003-12-31", "ACT_360", "1826", "5.072222" },
+ { "7Y", "1998-12-31", "2005-12-30", "ACT_360", "2556", "7.100000" },
+ { "10Y", "1998-12-31", "2008-12-31", "ACT_360", "3653", "10.147222" },
+ { "15Y", "1998-12-31", "2013-12-31", "ACT_360", "5479", "15.219444" },
+ { "20Y", "1998-12-31", "2018-12-31", "ACT_360", "7305", "20.291667" },
+ { "30Y", "1998-12-31", "2028-12-29", "ACT_360", "10956", "30.433333" }
+ // end of set
+ };
+
private static final String[][] CONV_30_360 = {
- // name start end period dayDiff yearDiff
- { "0D", "2006-08-08", "2006-08-08", "CONV_30_360", "0", "0.00" },
- { "1D", "2006-08-08", "2006-08-09", "CONV_30_360", "1", "0.002778" },
- { "1W", "2006-08-08", "2006-08-15", "CONV_30_360", "7", "0.019444" },
- { "1M", "2006-08-08", "2006-09-08", "CONV_30_360", "30", "0.083333" },
- { "3M", "2006-08-08", "2006-11-08", "CONV_30_360", "90", "0.250000" },
- { "6M", "2006-08-08", "2007-02-08", "CONV_30_360", "180", "0.500000" },
- { "9M", "2006-08-08", "2007-05-08", "CONV_30_360", "270", "0.750000" },
- { "1Y", "2006-08-08", "2007-08-08", "CONV_30_360", "360", "1.000000" },
- { "2Y", "2006-08-08", "2008-08-08", "CONV_30_360", "720", "2.000000" },
- { "3Y", "2006-08-08", "2009-08-10", "CONV_30_360", "1082", "3.005556" },
- { "4Y", "2006-08-08", "2010-08-09", "CONV_30_360", "1441", "4.002778" },
- { "5Y", "2006-08-08", "2011-08-08", "CONV_30_360", "1800", "5.000000" },
- { "7Y", "2006-08-08", "2013-08-08", "CONV_30_360", "2520", "7.000000" },
- { "10Y", "2006-08-08", "2016-08-08", "CONV_30_360", "3600", "10.000000" },
- { "15Y", "2006-08-08", "2021-08-09", "CONV_30_360", "5401", "15.002778" },
- { "20Y", "2006-08-08", "2026-08-10", "CONV_30_360", "7202", "20.005556" },
- { "30Y", "2006-08-08", "2036-08-08", "CONV_30_360", "10800", "30.000000" },
- // leap year - funny date...
- { "0D", "2008-02-29", "2008-02-29", "CONV_30_360", "0", "0.00" },
- { "1D", "2008-02-29", "2008-03-03", "CONV_30_360", "4", "0.011111" },
- { "1W", "2008-02-29", "2008-03-07", "CONV_30_360", "8", "0.022222" },
- { "1M", "2008-02-29", "2008-03-31", "CONV_30_360", "32", "0.088889" },
- { "3M", "2008-02-29", "2008-05-29", "CONV_30_360", "90", "0.250000" },
- { "6M", "2008-02-29", "2008-08-29", "CONV_30_360", "180", "0.500000" },
- { "9M", "2008-02-29", "2008-11-28", "CONV_30_360", "269", "0.747222" },
- { "1Y", "2008-02-29", "2009-02-27", "CONV_30_360", "358", "0.994444" },
- { "2Y", "2008-02-29", "2010-02-26", "CONV_30_360", "717", "1.991667" },
- { "3Y", "2008-02-29", "2011-02-28", "CONV_30_360", "1079", "2.997222" },
- { "4Y", "2008-02-29", "2012-02-29", "CONV_30_360", "1440", "4.000000" },
- { "5Y", "2008-02-29", "2013-02-28", "CONV_30_360", "1799", "4.997222" },
- { "7Y", "2008-02-29", "2015-02-27", "CONV_30_360", "2518", "6.994444" },
- { "10Y", "2008-02-29", "2018-02-28", "CONV_30_360", "3599", "9.997222" },
- { "15Y", "2008-02-29", "2023-02-28", "CONV_30_360", "5399", "14.997222" },
- { "20Y", "2008-02-29", "2028-02-29", "CONV_30_360", "7200", "20.000000" },
- { "30Y", "2008-02-29", "2038-02-26", "CONV_30_360", "10797", "29.991667" },
- // start date end of month...
- { "0D", "1998-12-31", "1998-12-31", "CONV_30_360", "0", "0.000000" },
- { "1D", "1998-12-31", "1999-01-01", "CONV_30_360", "1", "0.002778" },
- { "1W", "1998-12-31", "1999-01-07", "CONV_30_360", "7", "0.019444" },
- { "1M", "1998-12-31", "1999-01-29", "CONV_30_360", "29", "0.080556" },
- { "3M", "1998-12-31", "1999-03-31", "CONV_30_360", "90", "0.250000" },
- { "6M", "1998-12-31", "1999-06-30", "CONV_30_360", "180", "0.500000" },
- { "9M", "1998-12-31", "1999-09-30", "CONV_30_360", "270", "0.750000" },
- { "1Y", "1998-12-31", "1999-12-31", "CONV_30_360", "360", "1.000000" },
- { "2Y", "1998-12-31", "2000-12-29", "CONV_30_360", "719", "1.997222" },
- { "3Y", "1998-12-31", "2001-12-31", "CONV_30_360", "1080", "3.000000" },
- { "4Y", "1998-12-31", "2002-12-31", "CONV_30_360", "1440", "4.000000" },
- { "5Y", "1998-12-31", "2003-12-31", "CONV_30_360", "1800", "5.000000" },
- { "7Y", "1998-12-31", "2005-12-30", "CONV_30_360", "2520", "7.000000" },
- { "10Y", "1998-12-31", "2008-12-31", "CONV_30_360", "3600", "10.000000" },
- { "15Y", "1998-12-31", "2013-12-31", "CONV_30_360", "5400", "15.000000" },
- { "20Y", "1998-12-31", "2018-12-31", "CONV_30_360", "7200", "20.000000" },
- { "30Y", "1998-12-31", "2028-12-29", "CONV_30_360", "10799", "29.997222" }
- // end of set
- };
+ // name start end period dayDiff yearDiff
+ { "0D", "2006-08-08", "2006-08-08", "CONV_30_360", "0", "0.00" },
+ { "1D", "2006-08-08", "2006-08-09", "CONV_30_360", "1", "0.002778" },
+ { "1W", "2006-08-08", "2006-08-15", "CONV_30_360", "7", "0.019444" },
+ { "1M", "2006-08-08", "2006-09-08", "CONV_30_360", "30", "0.083333" },
+ { "3M", "2006-08-08", "2006-11-08", "CONV_30_360", "90", "0.250000" },
+ { "6M", "2006-08-08", "2007-02-08", "CONV_30_360", "180", "0.500000" },
+ { "9M", "2006-08-08", "2007-05-08", "CONV_30_360", "270", "0.750000" },
+ { "1Y", "2006-08-08", "2007-08-08", "CONV_30_360", "360", "1.000000" },
+ { "2Y", "2006-08-08", "2008-08-08", "CONV_30_360", "720", "2.000000" },
+ { "3Y", "2006-08-08", "2009-08-10", "CONV_30_360", "1082", "3.005556" },
+ { "4Y", "2006-08-08", "2010-08-09", "CONV_30_360", "1441", "4.002778" },
+ { "5Y", "2006-08-08", "2011-08-08", "CONV_30_360", "1800", "5.000000" },
+ { "7Y", "2006-08-08", "2013-08-08", "CONV_30_360", "2520", "7.000000" },
+ { "10Y", "2006-08-08", "2016-08-08", "CONV_30_360", "3600", "10.000000" },
+ { "15Y", "2006-08-08", "2021-08-09", "CONV_30_360", "5401", "15.002778" },
+ { "20Y", "2006-08-08", "2026-08-10", "CONV_30_360", "7202", "20.005556" },
+ { "30Y", "2006-08-08", "2036-08-08", "CONV_30_360", "10800", "30.000000" },
+ // leap year - funny date...
+ { "0D", "2008-02-29", "2008-02-29", "CONV_30_360", "0", "0.00" },
+ { "1D", "2008-02-29", "2008-03-03", "CONV_30_360", "4", "0.011111" },
+ { "1W", "2008-02-29", "2008-03-07", "CONV_30_360", "8", "0.022222" },
+ { "1M", "2008-02-29", "2008-03-31", "CONV_30_360", "32", "0.088889" },
+ { "3M", "2008-02-29", "2008-05-29", "CONV_30_360", "90", "0.250000" },
+ { "6M", "2008-02-29", "2008-08-29", "CONV_30_360", "180", "0.500000" },
+ { "9M", "2008-02-29", "2008-11-28", "CONV_30_360", "269", "0.747222" },
+ { "1Y", "2008-02-29", "2009-02-27", "CONV_30_360", "358", "0.994444" },
+ { "2Y", "2008-02-29", "2010-02-26", "CONV_30_360", "717", "1.991667" },
+ { "3Y", "2008-02-29", "2011-02-28", "CONV_30_360", "1079", "2.997222" },
+ { "4Y", "2008-02-29", "2012-02-29", "CONV_30_360", "1440", "4.000000" },
+ { "5Y", "2008-02-29", "2013-02-28", "CONV_30_360", "1799", "4.997222" },
+ { "7Y", "2008-02-29", "2015-02-27", "CONV_30_360", "2518", "6.994444" },
+ { "10Y", "2008-02-29", "2018-02-28", "CONV_30_360", "3599", "9.997222" },
+ { "15Y", "2008-02-29", "2023-02-28", "CONV_30_360", "5399", "14.997222" },
+ { "20Y", "2008-02-29", "2028-02-29", "CONV_30_360", "7200", "20.000000" },
+ { "30Y", "2008-02-29", "2038-02-26", "CONV_30_360", "10797", "29.991667" },
+ // start date end of month...
+ { "0D", "1998-12-31", "1998-12-31", "CONV_30_360", "0", "0.000000" },
+ { "1D", "1998-12-31", "1999-01-01", "CONV_30_360", "1", "0.002778" },
+ { "1W", "1998-12-31", "1999-01-07", "CONV_30_360", "7", "0.019444" },
+ { "1M", "1998-12-31", "1999-01-29", "CONV_30_360", "29", "0.080556" },
+ { "3M", "1998-12-31", "1999-03-31", "CONV_30_360", "90", "0.250000" },
+ { "6M", "1998-12-31", "1999-06-30", "CONV_30_360", "180", "0.500000" },
+ { "9M", "1998-12-31", "1999-09-30", "CONV_30_360", "270", "0.750000" },
+ { "1Y", "1998-12-31", "1999-12-31", "CONV_30_360", "360", "1.000000" },
+ { "2Y", "1998-12-31", "2000-12-29", "CONV_30_360", "719", "1.997222" },
+ { "3Y", "1998-12-31", "2001-12-31", "CONV_30_360", "1080", "3.000000" },
+ { "4Y", "1998-12-31", "2002-12-31", "CONV_30_360", "1440", "4.000000" },
+ { "5Y", "1998-12-31", "2003-12-31", "CONV_30_360", "1800", "5.000000" },
+ { "7Y", "1998-12-31", "2005-12-30", "CONV_30_360", "2520", "7.000000" },
+ { "10Y", "1998-12-31", "2008-12-31", "CONV_30_360", "3600", "10.000000" },
+ { "15Y", "1998-12-31", "2013-12-31", "CONV_30_360", "5400", "15.000000" },
+ { "20Y", "1998-12-31", "2018-12-31", "CONV_30_360", "7200", "20.000000" },
+ { "30Y", "1998-12-31", "2028-12-29", "CONV_30_360", "10799", "29.997222" }
+ // end of set
+ };
+
private static final String[][] CONV_360E_ISDA = {
- // name start end period dayDiff yearDiff
- { "0D", "2006-08-08", "2006-08-08", "CONV_360E_ISDA", "0", "0.00" },
- { "1D", "2006-08-08", "2006-08-09", "CONV_360E_ISDA", "1", "0.002778" },
- { "1W", "2006-08-08", "2006-08-15", "CONV_360E_ISDA", "7", "0.019444" },
- { "1M", "2006-08-08", "2006-09-08", "CONV_360E_ISDA", "30", "0.083333" },
- { "3M", "2006-08-08", "2006-11-08", "CONV_360E_ISDA", "90", "0.250000" },
- { "6M", "2006-08-08", "2007-02-08", "CONV_360E_ISDA", "180", "0.500000" },
- { "9M", "2006-08-08", "2007-05-08", "CONV_360E_ISDA", "270", "0.750000" },
- { "1Y", "2006-08-08", "2007-08-08", "CONV_360E_ISDA", "360", "1.000000" },
- { "2Y", "2006-08-08", "2008-08-08", "CONV_360E_ISDA", "720", "2.000000" },
- { "3Y", "2006-08-08", "2009-08-10", "CONV_360E_ISDA", "1082", "3.005556" },
- { "4Y", "2006-08-08", "2010-08-09", "CONV_360E_ISDA", "1441", "4.002778" },
- { "5Y", "2006-08-08", "2011-08-08", "CONV_360E_ISDA", "1800", "5.000000" },
- { "7Y", "2006-08-08", "2013-08-08", "CONV_360E_ISDA", "2520", "7.000000" },
- { "10Y", "2006-08-08", "2016-08-08", "CONV_360E_ISDA", "3600", "10.000000" },
- { "15Y", "2006-08-08", "2021-08-09", "CONV_360E_ISDA", "5401", "15.002778" },
- { "20Y", "2006-08-08", "2026-08-10", "CONV_360E_ISDA", "7202", "20.005556" },
- { "30Y", "2006-08-08", "2036-08-08", "CONV_360E_ISDA", "10800", "30.000000" },
- // leap year - funny date...
- { "0D", "2008-02-29", "2008-02-29", "CONV_360E_ISDA", "0", "0.00" },
- { "1D", "2008-02-29", "2008-03-03", "CONV_360E_ISDA", "4", "0.011111" },
- { "1W", "2008-02-29", "2008-03-07", "CONV_360E_ISDA", "8", "0.022222" },
- { "1M", "2008-02-29", "2008-03-31", "CONV_360E_ISDA", "31", "0.086111" },
- { "3M", "2008-02-29", "2008-05-29", "CONV_360E_ISDA", "90", "0.250000" },
- { "6M", "2008-02-29", "2008-08-29", "CONV_360E_ISDA", "180", "0.500000" },
- { "9M", "2008-02-29", "2008-11-28", "CONV_360E_ISDA", "269", "0.747222" },
- { "1Y", "2008-02-29", "2009-02-27", "CONV_360E_ISDA", "358", "0.994444" },
- { "2Y", "2008-02-29", "2010-02-26", "CONV_360E_ISDA", "717", "1.991667" },
- { "3Y", "2008-02-29", "2011-02-28", "CONV_360E_ISDA", "1079", "2.997222" },
- { "4Y", "2008-02-29", "2012-02-29", "CONV_360E_ISDA", "1440", "4.000000" },
- { "5Y", "2008-02-29", "2013-02-28", "CONV_360E_ISDA", "1799", "4.997222" },
- { "7Y", "2008-02-29", "2015-02-27", "CONV_360E_ISDA", "2518", "6.994444" },
- { "10Y", "2008-02-29", "2018-02-28", "CONV_360E_ISDA", "3599", "9.997222" },
- { "15Y", "2008-02-29", "2023-02-28", "CONV_360E_ISDA", "5399", "14.997222" },
- { "20Y", "2008-02-29", "2028-02-29", "CONV_360E_ISDA", "7200", "20.000000" },
- { "30Y", "2008-02-29", "2038-02-26", "CONV_360E_ISDA", "10797", "29.991667" },
- // start date end of month...
- { "0D", "1998-12-31", "1998-12-31", "CONV_360E_ISDA", "0", "0.00" },
- { "1D", "1998-12-31", "1999-01-01", "CONV_360E_ISDA", "1", "0.002778" },
- { "1W", "1998-12-31", "1999-01-07", "CONV_360E_ISDA", "7", "0.019444" },
- { "1M", "1998-12-31", "1999-01-29", "CONV_360E_ISDA", "29", "0.080556" },
- { "3M", "1998-12-31", "1999-03-31", "CONV_360E_ISDA", "90", "0.250000" },
- { "6M", "1998-12-31", "1999-06-30", "CONV_360E_ISDA", "180", "0.500000" },
- { "9M", "1998-12-31", "1999-09-30", "CONV_360E_ISDA", "270", "0.750000" },
- { "1Y", "1998-12-31", "1999-12-31", "CONV_360E_ISDA", "360", "1.000000" },
- { "2Y", "1998-12-31", "2000-12-29", "CONV_360E_ISDA", "719", "1.997222" },
- { "3Y", "1998-12-31", "2001-12-31", "CONV_360E_ISDA", "1080", "3.000000" },
- { "4Y", "1998-12-31", "2002-12-31", "CONV_360E_ISDA", "1440", "4.000000" },
- { "5Y", "1998-12-31", "2003-12-31", "CONV_360E_ISDA", "1800", "5.000000" },
- { "7Y", "1998-12-31", "2005-12-30", "CONV_360E_ISDA", "2520", "7.000000" },
- { "10Y", "1998-12-31", "2008-12-31", "CONV_360E_ISDA", "3600", "10.000000" },
- { "15Y", "1998-12-31", "2013-12-31", "CONV_360E_ISDA", "5400", "15.000000" },
- { "20Y", "1998-12-31", "2018-12-31", "CONV_360E_ISDA", "7200", "20.000000" },
- { "30Y", "1998-12-31", "2028-12-29", "CONV_360E_ISDA", "10799", "29.997222" }
- // end of set
- };
+ // name start end period dayDiff yearDiff
+ { "0D", "2006-08-08", "2006-08-08", "CONV_360E_ISDA", "0", "0.00" },
+ { "1D", "2006-08-08", "2006-08-09", "CONV_360E_ISDA", "1", "0.002778" },
+ { "1W", "2006-08-08", "2006-08-15", "CONV_360E_ISDA", "7", "0.019444" },
+ { "1M", "2006-08-08", "2006-09-08", "CONV_360E_ISDA", "30", "0.083333" },
+ { "3M", "2006-08-08", "2006-11-08", "CONV_360E_ISDA", "90", "0.250000" },
+ { "6M", "2006-08-08", "2007-02-08", "CONV_360E_ISDA", "180", "0.500000" },
+ { "9M", "2006-08-08", "2007-05-08", "CONV_360E_ISDA", "270", "0.750000" },
+ { "1Y", "2006-08-08", "2007-08-08", "CONV_360E_ISDA", "360", "1.000000" },
+ { "2Y", "2006-08-08", "2008-08-08", "CONV_360E_ISDA", "720", "2.000000" },
+ { "3Y", "2006-08-08", "2009-08-10", "CONV_360E_ISDA", "1082", "3.005556" },
+ { "4Y", "2006-08-08", "2010-08-09", "CONV_360E_ISDA", "1441", "4.002778" },
+ { "5Y", "2006-08-08", "2011-08-08", "CONV_360E_ISDA", "1800", "5.000000" },
+ { "7Y", "2006-08-08", "2013-08-08", "CONV_360E_ISDA", "2520", "7.000000" },
+ { "10Y", "2006-08-08", "2016-08-08", "CONV_360E_ISDA", "3600", "10.000000" },
+ { "15Y", "2006-08-08", "2021-08-09", "CONV_360E_ISDA", "5401", "15.002778" },
+ { "20Y", "2006-08-08", "2026-08-10", "CONV_360E_ISDA", "7202", "20.005556" },
+ { "30Y", "2006-08-08", "2036-08-08", "CONV_360E_ISDA", "10800", "30.000000" },
+ // leap year - funny date...
+ { "0D", "2008-02-29", "2008-02-29", "CONV_360E_ISDA", "0", "0.00" },
+ { "1D", "2008-02-29", "2008-03-03", "CONV_360E_ISDA", "4", "0.011111" },
+ { "1W", "2008-02-29", "2008-03-07", "CONV_360E_ISDA", "8", "0.022222" },
+ { "1M", "2008-02-29", "2008-03-31", "CONV_360E_ISDA", "31", "0.086111" },
+ { "3M", "2008-02-29", "2008-05-29", "CONV_360E_ISDA", "90", "0.250000" },
+ { "6M", "2008-02-29", "2008-08-29", "CONV_360E_ISDA", "180", "0.500000" },
+ { "9M", "2008-02-29", "2008-11-28", "CONV_360E_ISDA", "269", "0.747222" },
+ { "1Y", "2008-02-29", "2009-02-27", "CONV_360E_ISDA", "358", "0.994444" },
+ { "2Y", "2008-02-29", "2010-02-26", "CONV_360E_ISDA", "717", "1.991667" },
+ { "3Y", "2008-02-29", "2011-02-28", "CONV_360E_ISDA", "1079", "2.997222" },
+ { "4Y", "2008-02-29", "2012-02-29", "CONV_360E_ISDA", "1440", "4.000000" },
+ { "5Y", "2008-02-29", "2013-02-28", "CONV_360E_ISDA", "1799", "4.997222" },
+ { "7Y", "2008-02-29", "2015-02-27", "CONV_360E_ISDA", "2518", "6.994444" },
+ { "10Y", "2008-02-29", "2018-02-28", "CONV_360E_ISDA", "3599", "9.997222" },
+ { "15Y", "2008-02-29", "2023-02-28", "CONV_360E_ISDA", "5399", "14.997222" },
+ { "20Y", "2008-02-29", "2028-02-29", "CONV_360E_ISDA", "7200", "20.000000" },
+ { "30Y", "2008-02-29", "2038-02-26", "CONV_360E_ISDA", "10797", "29.991667" },
+ // start date end of month...
+ { "0D", "1998-12-31", "1998-12-31", "CONV_360E_ISDA", "0", "0.00" },
+ { "1D", "1998-12-31", "1999-01-01", "CONV_360E_ISDA", "1", "0.002778" },
+ { "1W", "1998-12-31", "1999-01-07", "CONV_360E_ISDA", "7", "0.019444" },
+ { "1M", "1998-12-31", "1999-01-29", "CONV_360E_ISDA", "29", "0.080556" },
+ { "3M", "1998-12-31", "1999-03-31", "CONV_360E_ISDA", "90", "0.250000" },
+ { "6M", "1998-12-31", "1999-06-30", "CONV_360E_ISDA", "180", "0.500000" },
+ { "9M", "1998-12-31", "1999-09-30", "CONV_360E_ISDA", "270", "0.750000" },
+ { "1Y", "1998-12-31", "1999-12-31", "CONV_360E_ISDA", "360", "1.000000" },
+ { "2Y", "1998-12-31", "2000-12-29", "CONV_360E_ISDA", "719", "1.997222" },
+ { "3Y", "1998-12-31", "2001-12-31", "CONV_360E_ISDA", "1080", "3.000000" },
+ { "4Y", "1998-12-31", "2002-12-31", "CONV_360E_ISDA", "1440", "4.000000" },
+ { "5Y", "1998-12-31", "2003-12-31", "CONV_360E_ISDA", "1800", "5.000000" },
+ { "7Y", "1998-12-31", "2005-12-30", "CONV_360E_ISDA", "2520", "7.000000" },
+ { "10Y", "1998-12-31", "2008-12-31", "CONV_360E_ISDA", "3600", "10.000000" },
+ { "15Y", "1998-12-31", "2013-12-31", "CONV_360E_ISDA", "5400", "15.000000" },
+ { "20Y", "1998-12-31", "2018-12-31", "CONV_360E_ISDA", "7200", "20.000000" },
+ { "30Y", "1998-12-31", "2028-12-29", "CONV_360E_ISDA", "10799", "29.997222" }
+ // end of set
+ };
+
private static final String[][] CONV_360E_ISMA = {
- // name start end period dayDiff yearDiff
- { "0D", "2006-08-08", "2006-08-08", "CONV_360E_ISMA", "0", "0.00" },
- { "1D", "2006-08-08", "2006-08-09", "CONV_360E_ISMA", "1", "0.002778" },
- { "1W", "2006-08-08", "2006-08-15", "CONV_360E_ISMA", "7", "0.019444" },
- { "1M", "2006-08-08", "2006-09-08", "CONV_360E_ISMA", "30", "0.083333" },
- { "3M", "2006-08-08", "2006-11-08", "CONV_360E_ISMA", "90", "0.250000" },
- { "6M", "2006-08-08", "2007-02-08", "CONV_360E_ISMA", "180", "0.500000" },
- { "9M", "2006-08-08", "2007-05-08", "CONV_360E_ISMA", "270", "0.750000" },
- { "1Y", "2006-08-08", "2007-08-08", "CONV_360E_ISMA", "360", "1.000000" },
- { "2Y", "2006-08-08", "2008-08-08", "CONV_360E_ISMA", "720", "2.000000" },
- { "3Y", "2006-08-08", "2009-08-10", "CONV_360E_ISMA", "1082", "3.005556" },
- { "4Y", "2006-08-08", "2010-08-09", "CONV_360E_ISMA", "1441", "4.002778" },
- { "5Y", "2006-08-08", "2011-08-08", "CONV_360E_ISMA", "1800", "5.000000" },
- { "7Y", "2006-08-08", "2013-08-08", "CONV_360E_ISMA", "2520", "7.000000" },
- { "10Y", "2006-08-08", "2016-08-08", "CONV_360E_ISMA", "3600", "10.000000" },
- { "15Y", "2006-08-08", "2021-08-09", "CONV_360E_ISMA", "5401"...
[truncated message content] |