1 /*
2 * ObjectLab, http://www.objectlab.co.uk/open is sponsoring the ObjectLab Kit.
3 *
4 * Based in London, we are world leaders in the design and development
5 * of bespoke applications for the securities financing markets.
6 *
7 * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
8 * ___ _ _ _ _ _
9 * / _ \| |__ (_) ___ ___| |_| | __ _| |__
10 * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
11 * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
12 * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
13 * |__/
14 *
15 * www.ObjectLab.co.uk
16 *
17 * $Id$
18 *
19 * Copyright 2006 the original author or authors.
20 *
21 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
22 * use this file except in compliance with the License. You may obtain a copy of
23 * the License at
24 *
25 * http://www.apache.org/licenses/LICENSE-2.0
26 *
27 * Unless required by applicable law or agreed to in writing, software
28 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
29 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
30 * License for the specific language governing permissions and limitations under
31 * the License.
32 */
33 package net.objectlab.kit.datecalc.joda;
34
35 import java.util.ArrayList;
36 import java.util.List;
37
38 import net.objectlab.kit.datecalc.common.AbstractIMMDateCalculator;
39 import net.objectlab.kit.datecalc.common.IMMPeriod;
40
41 import org.joda.time.LocalDate;
42 import org.joda.time.YearMonthDay;
43
44 /**
45 * Joda <code>YearMonthDay</code> based implementation of the
46 * {@link net.objectlab.kit.datecalc.common.IMMDateCalculator}
47 *
48 * @author Benoit Xhenseval
49 *
50 */
51 public class YearMonthDayIMMDateCalculator extends AbstractIMMDateCalculator<YearMonthDay> {
52
53 private static final LocalDateIMMDateCalculator DELEGATE = new LocalDateIMMDateCalculator();
54
55 public boolean isIMMDate(final YearMonthDay date) {
56 return DELEGATE.isIMMDate(date.toLocalDate());
57 }
58
59 @Override
60 protected YearMonthDay getNextIMMDate(final boolean requestNextIMM, final YearMonthDay theStartDate, final IMMPeriod period) {
61 return new YearMonthDay(DELEGATE.getNextIMMDate(requestNextIMM, theStartDate.toLocalDate(), period));
62 }
63
64 // -----------------------------------------------------------------------
65 //
66 // ObjectLab, world leaders in the design and development of bespoke
67 // applications for the securities financing markets.
68 // www.ObjectLab.co.uk
69 //
70 // -----------------------------------------------------------------------
71
72 public List<YearMonthDay> getIMMDates(final YearMonthDay start, final YearMonthDay end, final IMMPeriod period) {
73 return buildList(DELEGATE.getIMMDates(start.toLocalDate(), end.toLocalDate(), period));
74 }
75
76 private List<YearMonthDay> buildList(final List<LocalDate> dates) {
77 final List<YearMonthDay> imms = new ArrayList<YearMonthDay>();
78 for (final LocalDate date : dates) {
79 imms.add(new YearMonthDay(date));
80 }
81 return imms;
82 }
83 }
84
85 /*
86 * ObjectLab, http://www.objectlab.co.uk/open is sponsoring the ObjectLab Kit.
87 *
88 * Based in London, we are world leaders in the design and development
89 * of bespoke applications for the securities financing markets.
90 *
91 * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
92 * ___ _ _ _ _ _
93 * / _ \| |__ (_) ___ ___| |_| | __ _| |__
94 * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \
95 * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) |
96 * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
97 * |__/
98 *
99 * www.ObjectLab.co.uk
100 */