0001: /*
0002: * Copyright 2001-2005 Stephen Colebourne
0003: *
0004: * Licensed under the Apache License, Version 2.0 (the "License");
0005: * you may not use this file except in compliance with the License.
0006: * You may obtain a copy of the License at
0007: *
0008: * http://www.apache.org/licenses/LICENSE-2.0
0009: *
0010: * Unless required by applicable law or agreed to in writing, software
0011: * distributed under the License is distributed on an "AS IS" BASIS,
0012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013: * See the License for the specific language governing permissions and
0014: * limitations under the License.
0015: */
0016: package org.joda.time;
0017:
0018: import java.util.Locale;
0019: import java.util.TimeZone;
0020:
0021: import junit.framework.TestCase;
0022: import junit.framework.TestSuite;
0023:
0024: import org.joda.time.chrono.CopticChronology;
0025: import org.joda.time.chrono.ISOChronology;
0026:
0027: /**
0028: * This class is a JUnit test for MutableDuration.
0029: *
0030: * @author Stephen Colebourne
0031: */
0032: public class TestMutablePeriod_Constructors extends TestCase {
0033: // Test in 2002/03 as time zones are more well known
0034: // (before the late 90's they were all over the place)
0035:
0036: private static final DateTimeZone PARIS = DateTimeZone
0037: .forID("Europe/Paris");
0038: private static final DateTimeZone LONDON = DateTimeZone
0039: .forID("Europe/London");
0040:
0041: long y2002days = 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365
0042: + 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365
0043: + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365
0044: + 365 + 365 + 366 + 365;
0045: long y2003days = 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365
0046: + 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365
0047: + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365
0048: + 365 + 365 + 366 + 365 + 365;
0049:
0050: // 2002-06-09
0051: private long TEST_TIME_NOW = (y2002days + 31L + 28L + 31L + 30L
0052: + 31L + 9L - 1L)
0053: * DateTimeConstants.MILLIS_PER_DAY;
0054:
0055: // 2002-04-05
0056: private long TEST_TIME1 = (y2002days + 31L + 28L + 31L + 5L - 1L)
0057: * DateTimeConstants.MILLIS_PER_DAY + 12L
0058: * DateTimeConstants.MILLIS_PER_HOUR + 24L
0059: * DateTimeConstants.MILLIS_PER_MINUTE;
0060:
0061: // 2003-05-06
0062: private long TEST_TIME2 = (y2003days + 31L + 28L + 31L + 30L + 6L - 1L)
0063: * DateTimeConstants.MILLIS_PER_DAY
0064: + 14L
0065: * DateTimeConstants.MILLIS_PER_HOUR
0066: + 28L
0067: * DateTimeConstants.MILLIS_PER_MINUTE;
0068:
0069: private DateTimeZone originalDateTimeZone = null;
0070: private TimeZone originalTimeZone = null;
0071: private Locale originalLocale = null;
0072:
0073: public static void main(String[] args) {
0074: junit.textui.TestRunner.run(suite());
0075: }
0076:
0077: public static TestSuite suite() {
0078: return new TestSuite(TestMutablePeriod_Constructors.class);
0079: }
0080:
0081: public TestMutablePeriod_Constructors(String name) {
0082: super (name);
0083: }
0084:
0085: protected void setUp() throws Exception {
0086: DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
0087: originalDateTimeZone = DateTimeZone.getDefault();
0088: originalTimeZone = TimeZone.getDefault();
0089: originalLocale = Locale.getDefault();
0090: DateTimeZone.setDefault(LONDON);
0091: TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
0092: Locale.setDefault(Locale.UK);
0093: }
0094:
0095: protected void tearDown() throws Exception {
0096: DateTimeUtils.setCurrentMillisSystem();
0097: DateTimeZone.setDefault(originalDateTimeZone);
0098: TimeZone.setDefault(originalTimeZone);
0099: Locale.setDefault(originalLocale);
0100: originalDateTimeZone = null;
0101: originalTimeZone = null;
0102: originalLocale = null;
0103: }
0104:
0105: //-----------------------------------------------------------------------
0106: /**
0107: * Test constructor ()
0108: */
0109: public void testConstructor1() throws Throwable {
0110: MutablePeriod test = new MutablePeriod();
0111: assertEquals(PeriodType.standard(), test.getPeriodType());
0112: assertEquals(0, test.getYears());
0113: assertEquals(0, test.getMonths());
0114: assertEquals(0, test.getWeeks());
0115: assertEquals(0, test.getDays());
0116: assertEquals(0, test.getHours());
0117: assertEquals(0, test.getMinutes());
0118: assertEquals(0, test.getSeconds());
0119: assertEquals(0, test.getMillis());
0120: }
0121:
0122: //-----------------------------------------------------------------------
0123: /**
0124: * Test constructor (PeriodType)
0125: */
0126: public void testConstructor_PeriodType1() throws Throwable {
0127: MutablePeriod test = new MutablePeriod(PeriodType
0128: .yearMonthDayTime());
0129: assertEquals(PeriodType.yearMonthDayTime(), test
0130: .getPeriodType());
0131: assertEquals(0, test.getYears());
0132: assertEquals(0, test.getMonths());
0133: assertEquals(0, test.getWeeks());
0134: assertEquals(0, test.getDays());
0135: assertEquals(0, test.getHours());
0136: assertEquals(0, test.getMinutes());
0137: assertEquals(0, test.getSeconds());
0138: assertEquals(0, test.getMillis());
0139: }
0140:
0141: public void testConstructor_PeriodType2() throws Throwable {
0142: MutablePeriod test = new MutablePeriod((PeriodType) null);
0143: assertEquals(PeriodType.standard(), test.getPeriodType());
0144: assertEquals(0, test.getYears());
0145: assertEquals(0, test.getMonths());
0146: assertEquals(0, test.getWeeks());
0147: assertEquals(0, test.getDays());
0148: assertEquals(0, test.getHours());
0149: assertEquals(0, test.getMinutes());
0150: assertEquals(0, test.getSeconds());
0151: assertEquals(0, test.getMillis());
0152: }
0153:
0154: //-----------------------------------------------------------------------
0155: public void testConstructor_long1() throws Throwable {
0156: long length = 4 * DateTimeConstants.MILLIS_PER_DAY + 5
0157: * DateTimeConstants.MILLIS_PER_HOUR + 6
0158: * DateTimeConstants.MILLIS_PER_MINUTE + 7
0159: * DateTimeConstants.MILLIS_PER_SECOND + 8;
0160: MutablePeriod test = new MutablePeriod(length);
0161: assertEquals(PeriodType.standard(), test.getPeriodType());
0162: assertEquals(0, test.getYears());
0163: assertEquals(0, test.getMonths());
0164: assertEquals(0, test.getWeeks());
0165: assertEquals(0, test.getDays());
0166: assertEquals((4 * 24) + 5, test.getHours());
0167: assertEquals(6, test.getMinutes());
0168: assertEquals(7, test.getSeconds());
0169: assertEquals(8, test.getMillis());
0170: }
0171:
0172: public void testConstructor_long2() throws Throwable {
0173: long length = 5 * DateTimeConstants.MILLIS_PER_HOUR + 6
0174: * DateTimeConstants.MILLIS_PER_MINUTE + 7
0175: * DateTimeConstants.MILLIS_PER_SECOND + 8;
0176: MutablePeriod test = new MutablePeriod(length);
0177: assertEquals(PeriodType.standard(), test.getPeriodType());
0178: assertEquals(0, test.getYears());
0179: assertEquals(0, test.getMonths());
0180: assertEquals(0, test.getWeeks());
0181: assertEquals(0, test.getDays());
0182: assertEquals(5, test.getHours());
0183: assertEquals(6, test.getMinutes());
0184: assertEquals(7, test.getSeconds());
0185: assertEquals(8, test.getMillis());
0186: }
0187:
0188: public void testConstructor_long3() throws Throwable {
0189: long length = (4L + (3L * 7L) + (2L * 30L) + 365L)
0190: * DateTimeConstants.MILLIS_PER_DAY + 5L
0191: * DateTimeConstants.MILLIS_PER_HOUR + 6L
0192: * DateTimeConstants.MILLIS_PER_MINUTE + 7L
0193: * DateTimeConstants.MILLIS_PER_SECOND + 8L;
0194: MutablePeriod test = new MutablePeriod(length);
0195: assertEquals(PeriodType.standard(), test.getPeriodType());
0196: // only time fields are precise in AllType
0197: assertEquals(0, test.getYears()); // (4 + (3 * 7) + (2 * 30) + 365) == 450
0198: assertEquals(0, test.getMonths());
0199: assertEquals(0, test.getWeeks());
0200: assertEquals(0, test.getDays());
0201: assertEquals((450 * 24) + 5, test.getHours());
0202: assertEquals(6, test.getMinutes());
0203: assertEquals(7, test.getSeconds());
0204: assertEquals(8, test.getMillis());
0205: }
0206:
0207: //-----------------------------------------------------------------------
0208: public void testConstructor_long_PeriodType1() throws Throwable {
0209: long length = 4 * DateTimeConstants.MILLIS_PER_DAY + 5
0210: * DateTimeConstants.MILLIS_PER_HOUR + 6
0211: * DateTimeConstants.MILLIS_PER_MINUTE + 7
0212: * DateTimeConstants.MILLIS_PER_SECOND + 8;
0213: MutablePeriod test = new MutablePeriod(length,
0214: (PeriodType) null);
0215: assertEquals(PeriodType.standard(), test.getPeriodType());
0216: assertEquals(0, test.getYears());
0217: assertEquals(0, test.getMonths());
0218: assertEquals(0, test.getWeeks());
0219: assertEquals(0, test.getDays());
0220: assertEquals((4 * 24) + 5, test.getHours());
0221: assertEquals(6, test.getMinutes());
0222: assertEquals(7, test.getSeconds());
0223: assertEquals(8, test.getMillis());
0224: }
0225:
0226: public void testConstructor_long_PeriodType2() throws Throwable {
0227: long length = 4 * DateTimeConstants.MILLIS_PER_DAY + 5
0228: * DateTimeConstants.MILLIS_PER_HOUR + 6
0229: * DateTimeConstants.MILLIS_PER_MINUTE + 7
0230: * DateTimeConstants.MILLIS_PER_SECOND + 8;
0231: MutablePeriod test = new MutablePeriod(length, PeriodType
0232: .millis());
0233: assertEquals(PeriodType.millis(), test.getPeriodType());
0234: assertEquals(0, test.getYears());
0235: assertEquals(0, test.getMonths());
0236: assertEquals(0, test.getWeeks());
0237: assertEquals(0, test.getDays());
0238: assertEquals(0, test.getHours());
0239: assertEquals(0, test.getMinutes());
0240: assertEquals(0, test.getSeconds());
0241: assertEquals(length, test.getMillis());
0242: }
0243:
0244: public void testConstructor_long_PeriodType3() throws Throwable {
0245: long length = 4 * DateTimeConstants.MILLIS_PER_DAY + 5
0246: * DateTimeConstants.MILLIS_PER_HOUR + 6
0247: * DateTimeConstants.MILLIS_PER_MINUTE + 7
0248: * DateTimeConstants.MILLIS_PER_SECOND + 8;
0249: MutablePeriod test = new MutablePeriod(length, PeriodType
0250: .standard());
0251: assertEquals(PeriodType.standard(), test.getPeriodType());
0252: assertEquals(0, test.getYears());
0253: assertEquals(0, test.getMonths());
0254: assertEquals(0, test.getWeeks());
0255: assertEquals(0, test.getDays());
0256: assertEquals((4 * 24) + 5, test.getHours());
0257: assertEquals(6, test.getMinutes());
0258: assertEquals(7, test.getSeconds());
0259: assertEquals(8, test.getMillis());
0260: }
0261:
0262: public void testConstructor_long_PeriodType4() throws Throwable {
0263: long length = 5 * DateTimeConstants.MILLIS_PER_HOUR + 6
0264: * DateTimeConstants.MILLIS_PER_MINUTE + 7
0265: * DateTimeConstants.MILLIS_PER_SECOND + 8;
0266: MutablePeriod test = new MutablePeriod(length, PeriodType
0267: .standard().withMillisRemoved());
0268: assertEquals(PeriodType.standard().withMillisRemoved(), test
0269: .getPeriodType());
0270: assertEquals(0, test.getYears());
0271: assertEquals(0, test.getMonths());
0272: assertEquals(0, test.getWeeks());
0273: assertEquals(0, test.getDays());
0274: assertEquals(5, test.getHours());
0275: assertEquals(6, test.getMinutes());
0276: assertEquals(7, test.getSeconds());
0277: assertEquals(0, test.getMillis());
0278: }
0279:
0280: //-----------------------------------------------------------------------
0281: public void testConstructor_long_Chronology1() throws Throwable {
0282: long length = 4 * DateTimeConstants.MILLIS_PER_DAY + 5
0283: * DateTimeConstants.MILLIS_PER_HOUR + 6
0284: * DateTimeConstants.MILLIS_PER_MINUTE + 7
0285: * DateTimeConstants.MILLIS_PER_SECOND + 8;
0286: MutablePeriod test = new MutablePeriod(length, ISOChronology
0287: .getInstance());
0288: assertEquals(PeriodType.standard(), test.getPeriodType());
0289: assertEquals(0, test.getYears());
0290: assertEquals(0, test.getMonths());
0291: assertEquals(0, test.getWeeks());
0292: assertEquals(0, test.getDays());
0293: assertEquals((4 * 24) + 5, test.getHours());
0294: assertEquals(6, test.getMinutes());
0295: assertEquals(7, test.getSeconds());
0296: assertEquals(8, test.getMillis());
0297: }
0298:
0299: public void testConstructor_long_Chronology2() throws Throwable {
0300: long length = 4 * DateTimeConstants.MILLIS_PER_DAY + 5
0301: * DateTimeConstants.MILLIS_PER_HOUR + 6
0302: * DateTimeConstants.MILLIS_PER_MINUTE + 7
0303: * DateTimeConstants.MILLIS_PER_SECOND + 8;
0304: MutablePeriod test = new MutablePeriod(length, ISOChronology
0305: .getInstanceUTC());
0306: assertEquals(PeriodType.standard(), test.getPeriodType());
0307: assertEquals(0, test.getYears());
0308: assertEquals(0, test.getMonths());
0309: assertEquals(0, test.getWeeks());
0310: assertEquals(4, test.getDays());
0311: assertEquals(5, test.getHours());
0312: assertEquals(6, test.getMinutes());
0313: assertEquals(7, test.getSeconds());
0314: assertEquals(8, test.getMillis());
0315: }
0316:
0317: public void testConstructor_long_Chronology3() throws Throwable {
0318: long length = 4 * DateTimeConstants.MILLIS_PER_DAY + 5
0319: * DateTimeConstants.MILLIS_PER_HOUR + 6
0320: * DateTimeConstants.MILLIS_PER_MINUTE + 7
0321: * DateTimeConstants.MILLIS_PER_SECOND + 8;
0322: MutablePeriod test = new MutablePeriod(length,
0323: (Chronology) null);
0324: assertEquals(PeriodType.standard(), test.getPeriodType());
0325: assertEquals(0, test.getYears());
0326: assertEquals(0, test.getMonths());
0327: assertEquals(0, test.getWeeks());
0328: assertEquals(0, test.getDays());
0329: assertEquals((4 * 24) + 5, test.getHours());
0330: assertEquals(6, test.getMinutes());
0331: assertEquals(7, test.getSeconds());
0332: assertEquals(8, test.getMillis());
0333: }
0334:
0335: //-----------------------------------------------------------------------
0336: public void testConstructor_long_PeriodType_Chronology1()
0337: throws Throwable {
0338: long length = 4 * DateTimeConstants.MILLIS_PER_DAY + 5
0339: * DateTimeConstants.MILLIS_PER_HOUR + 6
0340: * DateTimeConstants.MILLIS_PER_MINUTE + 7
0341: * DateTimeConstants.MILLIS_PER_SECOND + 8;
0342: MutablePeriod test = new MutablePeriod(length, PeriodType
0343: .time().withMillisRemoved(), ISOChronology
0344: .getInstance());
0345: assertEquals(PeriodType.time().withMillisRemoved(), test
0346: .getPeriodType());
0347: assertEquals(0, test.getYears());
0348: assertEquals(0, test.getMonths());
0349: assertEquals(0, test.getWeeks());
0350: assertEquals(0, test.getDays());
0351: assertEquals((4 * 24) + 5, test.getHours());
0352: assertEquals(6, test.getMinutes());
0353: assertEquals(7, test.getSeconds());
0354: assertEquals(0, test.getMillis());
0355: }
0356:
0357: public void testConstructor_long_PeriodType_Chronology2()
0358: throws Throwable {
0359: long length = 4 * DateTimeConstants.MILLIS_PER_DAY + 5
0360: * DateTimeConstants.MILLIS_PER_HOUR + 6
0361: * DateTimeConstants.MILLIS_PER_MINUTE + 7
0362: * DateTimeConstants.MILLIS_PER_SECOND + 8;
0363: MutablePeriod test = new MutablePeriod(length, PeriodType
0364: .standard(), ISOChronology.getInstanceUTC());
0365: assertEquals(PeriodType.standard(), test.getPeriodType());
0366: assertEquals(0, test.getYears());
0367: assertEquals(0, test.getMonths());
0368: assertEquals(0, test.getWeeks());
0369: assertEquals(4, test.getDays());
0370: assertEquals(5, test.getHours());
0371: assertEquals(6, test.getMinutes());
0372: assertEquals(7, test.getSeconds());
0373: assertEquals(8, test.getMillis());
0374: }
0375:
0376: public void testConstructor_long_PeriodType_Chronology3()
0377: throws Throwable {
0378: long length = 4 * DateTimeConstants.MILLIS_PER_DAY + 5
0379: * DateTimeConstants.MILLIS_PER_HOUR + 6
0380: * DateTimeConstants.MILLIS_PER_MINUTE + 7
0381: * DateTimeConstants.MILLIS_PER_SECOND + 8;
0382: MutablePeriod test = new MutablePeriod(length, PeriodType
0383: .standard(), (Chronology) null);
0384: assertEquals(PeriodType.standard(), test.getPeriodType());
0385: assertEquals(0, test.getYears());
0386: assertEquals(0, test.getMonths());
0387: assertEquals(0, test.getWeeks());
0388: assertEquals(0, test.getDays());
0389: assertEquals((4 * 24) + 5, test.getHours());
0390: assertEquals(6, test.getMinutes());
0391: assertEquals(7, test.getSeconds());
0392: assertEquals(8, test.getMillis());
0393: }
0394:
0395: public void testConstructor_long_PeriodType_Chronology4()
0396: throws Throwable {
0397: long length = 4 * DateTimeConstants.MILLIS_PER_DAY + 5
0398: * DateTimeConstants.MILLIS_PER_HOUR + 6
0399: * DateTimeConstants.MILLIS_PER_MINUTE + 7
0400: * DateTimeConstants.MILLIS_PER_SECOND + 8;
0401: MutablePeriod test = new MutablePeriod(length,
0402: (PeriodType) null, (Chronology) null);
0403: assertEquals(PeriodType.standard(), test.getPeriodType());
0404: assertEquals(0, test.getYears());
0405: assertEquals(0, test.getMonths());
0406: assertEquals(0, test.getWeeks());
0407: assertEquals(0, test.getDays());
0408: assertEquals((4 * 24) + 5, test.getHours());
0409: assertEquals(6, test.getMinutes());
0410: assertEquals(7, test.getSeconds());
0411: assertEquals(8, test.getMillis());
0412: }
0413:
0414: //-----------------------------------------------------------------------
0415: /**
0416: * Test constructor (4ints)
0417: */
0418: public void testConstructor_4int1() throws Throwable {
0419: MutablePeriod test = new MutablePeriod(5, 6, 7, 8);
0420: assertEquals(PeriodType.standard(), test.getPeriodType());
0421: assertEquals(0, test.getYears());
0422: assertEquals(0, test.getMonths());
0423: assertEquals(0, test.getWeeks());
0424: assertEquals(0, test.getDays());
0425: assertEquals(5, test.getHours());
0426: assertEquals(6, test.getMinutes());
0427: assertEquals(7, test.getSeconds());
0428: assertEquals(8, test.getMillis());
0429: }
0430:
0431: //-----------------------------------------------------------------------
0432: /**
0433: * Test constructor (8ints)
0434: */
0435: public void testConstructor_8int1() throws Throwable {
0436: MutablePeriod test = new MutablePeriod(1, 2, 3, 4, 5, 6, 7, 8);
0437: assertEquals(PeriodType.standard(), test.getPeriodType());
0438: assertEquals(1, test.getYears());
0439: assertEquals(2, test.getMonths());
0440: assertEquals(3, test.getWeeks());
0441: assertEquals(4, test.getDays());
0442: assertEquals(5, test.getHours());
0443: assertEquals(6, test.getMinutes());
0444: assertEquals(7, test.getSeconds());
0445: assertEquals(8, test.getMillis());
0446: }
0447:
0448: //-----------------------------------------------------------------------
0449: /**
0450: * Test constructor (8ints)
0451: */
0452: public void testConstructor_8int__PeriodType1() throws Throwable {
0453: MutablePeriod test = new MutablePeriod(1, 2, 3, 4, 5, 6, 7, 8,
0454: null);
0455: assertEquals(PeriodType.standard(), test.getPeriodType());
0456: assertEquals(1, test.getYears());
0457: assertEquals(2, test.getMonths());
0458: assertEquals(3, test.getWeeks());
0459: assertEquals(4, test.getDays());
0460: assertEquals(5, test.getHours());
0461: assertEquals(6, test.getMinutes());
0462: assertEquals(7, test.getSeconds());
0463: assertEquals(8, test.getMillis());
0464: }
0465:
0466: public void testConstructor_8int__PeriodType2() throws Throwable {
0467: MutablePeriod test = new MutablePeriod(0, 0, 0, 0, 5, 6, 7, 8,
0468: PeriodType.dayTime());
0469: assertEquals(PeriodType.dayTime(), test.getPeriodType());
0470: assertEquals(0, test.getYears());
0471: assertEquals(0, test.getMonths());
0472: assertEquals(0, test.getWeeks());
0473: assertEquals(0, test.getDays());
0474: assertEquals(5, test.getHours());
0475: assertEquals(6, test.getMinutes());
0476: assertEquals(7, test.getSeconds());
0477: assertEquals(8, test.getMillis());
0478: }
0479:
0480: public void testConstructor_8int__PeriodType3() throws Throwable {
0481: try {
0482: new MutablePeriod(1, 2, 3, 4, 5, 6, 7, 8, PeriodType
0483: .dayTime());
0484: fail();
0485: } catch (IllegalArgumentException ex) {
0486: }
0487: }
0488:
0489: //-----------------------------------------------------------------------
0490: public void testConstructor_long_long1() throws Throwable {
0491: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0492: DateTime dt2 = new DateTime(2005, 7, 10, 1, 1, 1, 1);
0493: MutablePeriod test = new MutablePeriod(dt1.getMillis(), dt2
0494: .getMillis());
0495: assertEquals(PeriodType.standard(), test.getPeriodType());
0496: assertEquals(1, test.getYears());
0497: assertEquals(1, test.getMonths());
0498: assertEquals(0, test.getWeeks());
0499: assertEquals(1, test.getDays());
0500: assertEquals(1, test.getHours());
0501: assertEquals(1, test.getMinutes());
0502: assertEquals(1, test.getSeconds());
0503: assertEquals(1, test.getMillis());
0504: }
0505:
0506: public void testConstructor_long_long2() throws Throwable {
0507: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0508: DateTime dt2 = new DateTime(2005, 7, 17, 1, 1, 1, 1);
0509: MutablePeriod test = new MutablePeriod(dt1.getMillis(), dt2
0510: .getMillis());
0511: assertEquals(PeriodType.standard(), test.getPeriodType());
0512: assertEquals(1, test.getYears());
0513: assertEquals(1, test.getMonths());
0514: assertEquals(1, test.getWeeks());
0515: assertEquals(1, test.getDays());
0516: assertEquals(1, test.getHours());
0517: assertEquals(1, test.getMinutes());
0518: assertEquals(1, test.getSeconds());
0519: assertEquals(1, test.getMillis());
0520: }
0521:
0522: //-----------------------------------------------------------------------
0523: public void testConstructor_long_long_PeriodType1()
0524: throws Throwable {
0525: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0526: DateTime dt2 = new DateTime(2005, 7, 10, 1, 1, 1, 1);
0527: MutablePeriod test = new MutablePeriod(dt1.getMillis(), dt2
0528: .getMillis(), (PeriodType) null);
0529: assertEquals(PeriodType.standard(), test.getPeriodType());
0530: assertEquals(1, test.getYears());
0531: assertEquals(1, test.getMonths());
0532: assertEquals(0, test.getWeeks());
0533: assertEquals(1, test.getDays());
0534: assertEquals(1, test.getHours());
0535: assertEquals(1, test.getMinutes());
0536: assertEquals(1, test.getSeconds());
0537: assertEquals(1, test.getMillis());
0538: }
0539:
0540: public void testConstructor_long_long_PeriodType2()
0541: throws Throwable {
0542: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0543: DateTime dt2 = new DateTime(2004, 7, 10, 1, 1, 1, 1);
0544: MutablePeriod test = new MutablePeriod(dt1.getMillis(), dt2
0545: .getMillis(), PeriodType.dayTime());
0546: assertEquals(PeriodType.dayTime(), test.getPeriodType());
0547: assertEquals(0, test.getYears());
0548: assertEquals(0, test.getMonths());
0549: assertEquals(0, test.getWeeks());
0550: assertEquals(31, test.getDays());
0551: assertEquals(1, test.getHours());
0552: assertEquals(1, test.getMinutes());
0553: assertEquals(1, test.getSeconds());
0554: assertEquals(1, test.getMillis());
0555: }
0556:
0557: public void testConstructor_long_long_PeriodType3()
0558: throws Throwable {
0559: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0560: DateTime dt2 = new DateTime(2004, 6, 9, 1, 1, 1, 1);
0561: MutablePeriod test = new MutablePeriod(dt1.getMillis(), dt2
0562: .getMillis(), PeriodType.standard().withMillisRemoved());
0563: assertEquals(PeriodType.standard().withMillisRemoved(), test
0564: .getPeriodType());
0565: assertEquals(0, test.getYears());
0566: assertEquals(0, test.getMonths());
0567: assertEquals(0, test.getWeeks());
0568: assertEquals(0, test.getDays());
0569: assertEquals(1, test.getHours());
0570: assertEquals(1, test.getMinutes());
0571: assertEquals(1, test.getSeconds());
0572: assertEquals(0, test.getMillis());
0573: }
0574:
0575: //-----------------------------------------------------------------------
0576: public void testConstructor_long_long_Chronology1()
0577: throws Throwable {
0578: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0,
0579: CopticChronology.getInstance());
0580: DateTime dt2 = new DateTime(2005, 7, 10, 1, 1, 1, 1,
0581: CopticChronology.getInstance());
0582: MutablePeriod test = new MutablePeriod(dt1.getMillis(), dt2
0583: .getMillis(), CopticChronology.getInstance());
0584: assertEquals(PeriodType.standard(), test.getPeriodType());
0585: assertEquals(1, test.getYears());
0586: assertEquals(1, test.getMonths());
0587: assertEquals(0, test.getWeeks());
0588: assertEquals(1, test.getDays());
0589: assertEquals(1, test.getHours());
0590: assertEquals(1, test.getMinutes());
0591: assertEquals(1, test.getSeconds());
0592: assertEquals(1, test.getMillis());
0593: }
0594:
0595: public void testConstructor_long_long_Chronology2()
0596: throws Throwable {
0597: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0598: DateTime dt2 = new DateTime(2005, 7, 10, 1, 1, 1, 1);
0599: MutablePeriod test = new MutablePeriod(dt1.getMillis(), dt2
0600: .getMillis(), (Chronology) null);
0601: assertEquals(PeriodType.standard(), test.getPeriodType());
0602: assertEquals(1, test.getYears());
0603: assertEquals(1, test.getMonths());
0604: assertEquals(0, test.getWeeks());
0605: assertEquals(1, test.getDays());
0606: assertEquals(1, test.getHours());
0607: assertEquals(1, test.getMinutes());
0608: assertEquals(1, test.getSeconds());
0609: assertEquals(1, test.getMillis());
0610: }
0611:
0612: //-----------------------------------------------------------------------
0613: public void testConstructor_long_long_PeriodType_Chronology1()
0614: throws Throwable {
0615: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0,
0616: CopticChronology.getInstance());
0617: DateTime dt2 = new DateTime(2005, 7, 10, 1, 1, 1, 1,
0618: CopticChronology.getInstance());
0619: MutablePeriod test = new MutablePeriod(dt1.getMillis(), dt2
0620: .getMillis(), (PeriodType) null, CopticChronology
0621: .getInstance());
0622: assertEquals(PeriodType.standard(), test.getPeriodType());
0623: assertEquals(1, test.getYears());
0624: assertEquals(1, test.getMonths());
0625: assertEquals(0, test.getWeeks());
0626: assertEquals(1, test.getDays());
0627: assertEquals(1, test.getHours());
0628: assertEquals(1, test.getMinutes());
0629: assertEquals(1, test.getSeconds());
0630: assertEquals(1, test.getMillis());
0631: }
0632:
0633: public void testConstructor_long_long_PeriodType_Chronology2()
0634: throws Throwable {
0635: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0636: DateTime dt2 = new DateTime(2005, 7, 10, 1, 1, 1, 1);
0637: MutablePeriod test = new MutablePeriod(dt1.getMillis(), dt2
0638: .getMillis(), (PeriodType) null, null);
0639: assertEquals(PeriodType.standard(), test.getPeriodType());
0640: assertEquals(1, test.getYears());
0641: assertEquals(1, test.getMonths());
0642: assertEquals(0, test.getWeeks());
0643: assertEquals(1, test.getDays());
0644: assertEquals(1, test.getHours());
0645: assertEquals(1, test.getMinutes());
0646: assertEquals(1, test.getSeconds());
0647: assertEquals(1, test.getMillis());
0648: }
0649:
0650: //-----------------------------------------------------------------------
0651: public void testConstructor_RI_RI1() throws Throwable {
0652: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0653: DateTime dt2 = new DateTime(2005, 7, 10, 1, 1, 1, 1);
0654: MutablePeriod test = new MutablePeriod(dt1, dt2);
0655: assertEquals(PeriodType.standard(), test.getPeriodType());
0656: assertEquals(1, test.getYears());
0657: assertEquals(1, test.getMonths());
0658: assertEquals(0, test.getWeeks());
0659: assertEquals(1, test.getDays());
0660: assertEquals(1, test.getHours());
0661: assertEquals(1, test.getMinutes());
0662: assertEquals(1, test.getSeconds());
0663: assertEquals(1, test.getMillis());
0664: }
0665:
0666: public void testConstructor_RI_RI2() throws Throwable {
0667: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0668: DateTime dt2 = new DateTime(2005, 7, 17, 1, 1, 1, 1);
0669: MutablePeriod test = new MutablePeriod(dt1, dt2);
0670: assertEquals(PeriodType.standard(), test.getPeriodType());
0671: assertEquals(1, test.getYears());
0672: assertEquals(1, test.getMonths());
0673: assertEquals(1, test.getWeeks());
0674: assertEquals(1, test.getDays());
0675: assertEquals(1, test.getHours());
0676: assertEquals(1, test.getMinutes());
0677: assertEquals(1, test.getSeconds());
0678: assertEquals(1, test.getMillis());
0679: }
0680:
0681: public void testConstructor_RI_RI3() throws Throwable {
0682: DateTime dt1 = null; // 2002-06-09T01:00+01:00
0683: DateTime dt2 = new DateTime(2005, 7, 17, 1, 1, 1, 1);
0684: MutablePeriod test = new MutablePeriod(dt1, dt2);
0685: assertEquals(PeriodType.standard(), test.getPeriodType());
0686: assertEquals(3, test.getYears());
0687: assertEquals(1, test.getMonths());
0688: assertEquals(1, test.getWeeks());
0689: assertEquals(1, test.getDays());
0690: assertEquals(0, test.getHours());
0691: assertEquals(1, test.getMinutes());
0692: assertEquals(1, test.getSeconds());
0693: assertEquals(1, test.getMillis());
0694: }
0695:
0696: public void testConstructor_RI_RI4() throws Throwable {
0697: DateTime dt1 = new DateTime(2005, 7, 17, 1, 1, 1, 1);
0698: DateTime dt2 = null; // 2002-06-09T01:00+01:00
0699: MutablePeriod test = new MutablePeriod(dt1, dt2);
0700: assertEquals(PeriodType.standard(), test.getPeriodType());
0701: assertEquals(-3, test.getYears());
0702: assertEquals(-1, test.getMonths());
0703: assertEquals(-1, test.getWeeks());
0704: assertEquals(-1, test.getDays());
0705: assertEquals(0, test.getHours());
0706: assertEquals(-1, test.getMinutes());
0707: assertEquals(-1, test.getSeconds());
0708: assertEquals(-1, test.getMillis());
0709: }
0710:
0711: public void testConstructor_RI_RI5() throws Throwable {
0712: DateTime dt1 = null; // 2002-06-09T01:00+01:00
0713: DateTime dt2 = null; // 2002-06-09T01:00+01:00
0714: MutablePeriod test = new MutablePeriod(dt1, dt2);
0715: assertEquals(PeriodType.standard(), test.getPeriodType());
0716: assertEquals(0, test.getYears());
0717: assertEquals(0, test.getMonths());
0718: assertEquals(0, test.getWeeks());
0719: assertEquals(0, test.getDays());
0720: assertEquals(0, test.getHours());
0721: assertEquals(0, test.getMinutes());
0722: assertEquals(0, test.getSeconds());
0723: assertEquals(0, test.getMillis());
0724: }
0725:
0726: //-----------------------------------------------------------------------
0727: public void testConstructor_RI_RI_PeriodType1() throws Throwable {
0728: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0729: DateTime dt2 = new DateTime(2005, 7, 10, 1, 1, 1, 1);
0730: MutablePeriod test = new MutablePeriod(dt1, dt2, null);
0731: assertEquals(PeriodType.standard(), test.getPeriodType());
0732: assertEquals(1, test.getYears());
0733: assertEquals(1, test.getMonths());
0734: assertEquals(0, test.getWeeks());
0735: assertEquals(1, test.getDays());
0736: assertEquals(1, test.getHours());
0737: assertEquals(1, test.getMinutes());
0738: assertEquals(1, test.getSeconds());
0739: assertEquals(1, test.getMillis());
0740: }
0741:
0742: public void testConstructor_RI_RI_PeriodType2() throws Throwable {
0743: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0744: DateTime dt2 = new DateTime(2004, 7, 10, 1, 1, 1, 1);
0745: MutablePeriod test = new MutablePeriod(dt1, dt2, PeriodType
0746: .dayTime());
0747: assertEquals(PeriodType.dayTime(), test.getPeriodType());
0748: assertEquals(0, test.getYears());
0749: assertEquals(0, test.getMonths());
0750: assertEquals(0, test.getWeeks());
0751: assertEquals(31, test.getDays());
0752: assertEquals(1, test.getHours());
0753: assertEquals(1, test.getMinutes());
0754: assertEquals(1, test.getSeconds());
0755: assertEquals(1, test.getMillis());
0756: }
0757:
0758: public void testConstructor_RI_RI_PeriodType3() throws Throwable {
0759: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0760: DateTime dt2 = new DateTime(2004, 6, 9, 1, 1, 1, 1);
0761: MutablePeriod test = new MutablePeriod(dt1, dt2, PeriodType
0762: .standard().withMillisRemoved());
0763: assertEquals(PeriodType.standard().withMillisRemoved(), test
0764: .getPeriodType());
0765: assertEquals(0, test.getYears());
0766: assertEquals(0, test.getMonths());
0767: assertEquals(0, test.getWeeks());
0768: assertEquals(0, test.getDays());
0769: assertEquals(1, test.getHours());
0770: assertEquals(1, test.getMinutes());
0771: assertEquals(1, test.getSeconds());
0772: assertEquals(0, test.getMillis());
0773: }
0774:
0775: public void testConstructor_RI_RI_PeriodType4() throws Throwable {
0776: DateTime dt1 = null; // 2002-06-09T01:00+01:00
0777: DateTime dt2 = new DateTime(2005, 7, 17, 1, 1, 1, 1);
0778: MutablePeriod test = new MutablePeriod(dt1, dt2, PeriodType
0779: .standard());
0780: assertEquals(PeriodType.standard(), test.getPeriodType());
0781: assertEquals(3, test.getYears());
0782: assertEquals(1, test.getMonths());
0783: assertEquals(1, test.getWeeks());
0784: assertEquals(1, test.getDays());
0785: assertEquals(0, test.getHours());
0786: assertEquals(1, test.getMinutes());
0787: assertEquals(1, test.getSeconds());
0788: assertEquals(1, test.getMillis());
0789: }
0790:
0791: public void testConstructor_RI_RI_PeriodType5() throws Throwable {
0792: DateTime dt1 = null; // 2002-06-09T01:00+01:00
0793: DateTime dt2 = null; // 2002-06-09T01:00+01:00
0794: MutablePeriod test = new MutablePeriod(dt1, dt2, PeriodType
0795: .standard());
0796: assertEquals(PeriodType.standard(), test.getPeriodType());
0797: assertEquals(0, test.getYears());
0798: assertEquals(0, test.getMonths());
0799: assertEquals(0, test.getWeeks());
0800: assertEquals(0, test.getDays());
0801: assertEquals(0, test.getHours());
0802: assertEquals(0, test.getMinutes());
0803: assertEquals(0, test.getSeconds());
0804: assertEquals(0, test.getMillis());
0805: }
0806:
0807: //-----------------------------------------------------------------------
0808: public void testConstructor_RI_RD1() throws Throwable {
0809: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0810: DateTime dt2 = new DateTime(2005, 7, 10, 1, 1, 1, 1);
0811: Duration dur = new Interval(dt1, dt2).toDuration();
0812: MutablePeriod test = new MutablePeriod(dt1, dur);
0813: assertEquals(PeriodType.standard(), test.getPeriodType());
0814: assertEquals(1, test.getYears());
0815: assertEquals(1, test.getMonths());
0816: assertEquals(0, test.getWeeks());
0817: assertEquals(1, test.getDays());
0818: assertEquals(1, test.getHours());
0819: assertEquals(1, test.getMinutes());
0820: assertEquals(1, test.getSeconds());
0821: assertEquals(1, test.getMillis());
0822: }
0823:
0824: public void testConstructor_RI_RD2() throws Throwable {
0825: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0826: Duration dur = null;
0827: MutablePeriod test = new MutablePeriod(dt1, dur);
0828: assertEquals(PeriodType.standard(), test.getPeriodType());
0829: assertEquals(0, test.getYears());
0830: assertEquals(0, test.getMonths());
0831: assertEquals(0, test.getWeeks());
0832: assertEquals(0, test.getDays());
0833: assertEquals(0, test.getHours());
0834: assertEquals(0, test.getMinutes());
0835: assertEquals(0, test.getSeconds());
0836: assertEquals(0, test.getMillis());
0837: }
0838:
0839: //-----------------------------------------------------------------------
0840: public void testConstructor_RI_RD_PeriodType1() throws Throwable {
0841: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0842: DateTime dt2 = new DateTime(2005, 7, 10, 1, 1, 1, 1);
0843: Duration dur = new Interval(dt1, dt2).toDuration();
0844: MutablePeriod test = new MutablePeriod(dt1, dur, PeriodType
0845: .yearDayTime());
0846: assertEquals(PeriodType.yearDayTime(), test.getPeriodType());
0847: assertEquals(1, test.getYears());
0848: assertEquals(0, test.getMonths());
0849: assertEquals(0, test.getWeeks());
0850: assertEquals(31, test.getDays());
0851: assertEquals(1, test.getHours());
0852: assertEquals(1, test.getMinutes());
0853: assertEquals(1, test.getSeconds());
0854: assertEquals(1, test.getMillis());
0855: }
0856:
0857: public void testConstructor_RI_RD_PeriodType2() throws Throwable {
0858: DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0859: Duration dur = null;
0860: MutablePeriod test = new MutablePeriod(dt1, dur,
0861: (PeriodType) null);
0862: assertEquals(PeriodType.standard(), test.getPeriodType());
0863: assertEquals(0, test.getYears());
0864: assertEquals(0, test.getMonths());
0865: assertEquals(0, test.getWeeks());
0866: assertEquals(0, test.getDays());
0867: assertEquals(0, test.getHours());
0868: assertEquals(0, test.getMinutes());
0869: assertEquals(0, test.getSeconds());
0870: assertEquals(0, test.getMillis());
0871: }
0872:
0873: //-----------------------------------------------------------------------
0874: /**
0875: * Test constructor (Object)
0876: */
0877: public void testConstructor_Object1() throws Throwable {
0878: MutablePeriod test = new MutablePeriod("P1Y2M3D");
0879: assertEquals(PeriodType.standard(), test.getPeriodType());
0880: assertEquals(1, test.getYears());
0881: assertEquals(2, test.getMonths());
0882: assertEquals(0, test.getWeeks());
0883: assertEquals(3, test.getDays());
0884: assertEquals(0, test.getHours());
0885: assertEquals(0, test.getMinutes());
0886: assertEquals(0, test.getSeconds());
0887: assertEquals(0, test.getMillis());
0888: }
0889:
0890: public void testConstructor_Object2() throws Throwable {
0891: MutablePeriod test = new MutablePeriod((Object) null);
0892: assertEquals(PeriodType.standard(), test.getPeriodType());
0893: assertEquals(0, test.getYears());
0894: assertEquals(0, test.getMonths());
0895: assertEquals(0, test.getWeeks());
0896: assertEquals(0, test.getDays());
0897: assertEquals(0, test.getHours());
0898: assertEquals(0, test.getMinutes());
0899: assertEquals(0, test.getSeconds());
0900: assertEquals(0, test.getMillis());
0901: }
0902:
0903: public void testConstructor_Object3() throws Throwable {
0904: MutablePeriod test = new MutablePeriod(new Period(0, 0, 0, 0,
0905: 1, 2, 3, 4, PeriodType.dayTime()));
0906: assertEquals(PeriodType.dayTime(), test.getPeriodType());
0907: assertEquals(0, test.getYears());
0908: assertEquals(0, test.getMonths());
0909: assertEquals(0, test.getWeeks());
0910: assertEquals(0, test.getDays());
0911: assertEquals(1, test.getHours());
0912: assertEquals(2, test.getMinutes());
0913: assertEquals(3, test.getSeconds());
0914: assertEquals(4, test.getMillis());
0915: }
0916:
0917: public void testConstructor_Object4() throws Throwable {
0918: Period base = new Period(1, 1, 0, 1, 1, 1, 1, 1, PeriodType
0919: .standard());
0920: MutablePeriod test = new MutablePeriod(base);
0921: assertEquals(PeriodType.standard(), test.getPeriodType());
0922: assertEquals(1, test.getYears());
0923: assertEquals(1, test.getMonths());
0924: assertEquals(0, test.getWeeks());
0925: assertEquals(1, test.getDays());
0926: assertEquals(1, test.getHours());
0927: assertEquals(1, test.getMinutes());
0928: assertEquals(1, test.getSeconds());
0929: assertEquals(1, test.getMillis());
0930: }
0931:
0932: //-----------------------------------------------------------------------
0933: /**
0934: * Test constructor (Object,PeriodType)
0935: */
0936: public void testConstructor_Object_PeriodType1() throws Throwable {
0937: MutablePeriod test = new MutablePeriod("P1Y2M3D", PeriodType
0938: .yearMonthDayTime());
0939: assertEquals(PeriodType.yearMonthDayTime(), test
0940: .getPeriodType());
0941: assertEquals(1, test.getYears());
0942: assertEquals(2, test.getMonths());
0943: assertEquals(0, test.getWeeks());
0944: assertEquals(3, test.getDays());
0945: assertEquals(0, test.getHours());
0946: assertEquals(0, test.getMinutes());
0947: assertEquals(0, test.getSeconds());
0948: assertEquals(0, test.getMillis());
0949: }
0950:
0951: public void testConstructor_Object_PeriodType2() throws Throwable {
0952: MutablePeriod test = new MutablePeriod((Object) null,
0953: PeriodType.yearMonthDayTime());
0954: assertEquals(PeriodType.yearMonthDayTime(), test
0955: .getPeriodType());
0956: assertEquals(0, test.getYears());
0957: assertEquals(0, test.getMonths());
0958: assertEquals(0, test.getWeeks());
0959: assertEquals(0, test.getDays());
0960: assertEquals(0, test.getHours());
0961: assertEquals(0, test.getMinutes());
0962: assertEquals(0, test.getSeconds());
0963: assertEquals(0, test.getMillis());
0964: }
0965:
0966: public void testConstructor_Object_PeriodType3() throws Throwable {
0967: MutablePeriod test = new MutablePeriod(new Period(0, 0, 0, 0,
0968: 1, 2, 3, 4, PeriodType.dayTime()), PeriodType
0969: .yearMonthDayTime());
0970: assertEquals(PeriodType.yearMonthDayTime(), test
0971: .getPeriodType());
0972: assertEquals(0, test.getYears());
0973: assertEquals(0, test.getMonths());
0974: assertEquals(0, test.getWeeks());
0975: assertEquals(0, test.getDays());
0976: assertEquals(1, test.getHours());
0977: assertEquals(2, test.getMinutes());
0978: assertEquals(3, test.getSeconds());
0979: assertEquals(4, test.getMillis());
0980: }
0981:
0982: public void testConstructor_Object_PeriodType4() throws Throwable {
0983: MutablePeriod test = new MutablePeriod(new Period(0, 0, 0, 0,
0984: 1, 2, 3, 4, PeriodType.dayTime()), (PeriodType) null);
0985: assertEquals(PeriodType.dayTime(), test.getPeriodType());
0986: assertEquals(0, test.getYears());
0987: assertEquals(0, test.getMonths());
0988: assertEquals(0, test.getWeeks());
0989: assertEquals(0, test.getDays());
0990: assertEquals(1, test.getHours());
0991: assertEquals(2, test.getMinutes());
0992: assertEquals(3, test.getSeconds());
0993: assertEquals(4, test.getMillis());
0994: }
0995:
0996: //-----------------------------------------------------------------------
0997: public void testConstructor_Object_Chronology1() throws Throwable {
0998: long length = (4L + (3L * 7L) + (2L * 30L) + 365L)
0999: * DateTimeConstants.MILLIS_PER_DAY + 5L
1000: * DateTimeConstants.MILLIS_PER_HOUR + 6L
1001: * DateTimeConstants.MILLIS_PER_MINUTE + 7L
1002: * DateTimeConstants.MILLIS_PER_SECOND + 8L;
1003: MutablePeriod test = new MutablePeriod(new Duration(length),
1004: ISOChronology.getInstance());
1005: assertEquals(PeriodType.standard(), test.getPeriodType());
1006: assertEquals(0, test.getYears()); // (4 + (3 * 7) + (2 * 30) + 365) == 450
1007: assertEquals(0, test.getMonths());
1008: assertEquals(0, test.getWeeks());
1009: assertEquals(0, test.getDays());
1010: assertEquals((450 * 24) + 5, test.getHours());
1011: assertEquals(6, test.getMinutes());
1012: assertEquals(7, test.getSeconds());
1013: assertEquals(8, test.getMillis());
1014: }
1015:
1016: public void testConstructor_Object_Chronology2() throws Throwable {
1017: long length = (4L + (3L * 7L) + (2L * 30L) + 365L)
1018: * DateTimeConstants.MILLIS_PER_DAY + 5L
1019: * DateTimeConstants.MILLIS_PER_HOUR + 6L
1020: * DateTimeConstants.MILLIS_PER_MINUTE + 7L
1021: * DateTimeConstants.MILLIS_PER_SECOND + 8L;
1022: MutablePeriod test = new MutablePeriod(new Duration(length),
1023: ISOChronology.getInstanceUTC());
1024: assertEquals(PeriodType.standard(), test.getPeriodType());
1025: assertEquals(0, test.getYears()); // (4 + (3 * 7) + (2 * 30) + 365) == 450
1026: assertEquals(0, test.getMonths());
1027: assertEquals(64, test.getWeeks());
1028: assertEquals(2, test.getDays());
1029: assertEquals(5, test.getHours());
1030: assertEquals(6, test.getMinutes());
1031: assertEquals(7, test.getSeconds());
1032: assertEquals(8, test.getMillis());
1033: }
1034:
1035: }
|