Source Code Cross Referenced for TestDateTime_Properties.java in  » Development » Joda-Time » org » joda » time » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Development » Joda Time » org.joda.time 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:
0020:        import junit.framework.TestCase;
0021:        import junit.framework.TestSuite;
0022:
0023:        import org.joda.time.chrono.CopticChronology;
0024:        import org.joda.time.chrono.LenientChronology;
0025:        import org.joda.time.chrono.StrictChronology;
0026:
0027:        /**
0028:         * This class is a Junit unit test for DateTime.
0029:         *
0030:         * @author Stephen Colebourne
0031:         * @author Mike Schrag
0032:         */
0033:        public class TestDateTime_Properties extends TestCase {
0034:            // Test in 2002/03 as time zones are more well known
0035:            // (before the late 90's they were all over the place)
0036:
0037:            private static final DateTimeZone PARIS = DateTimeZone
0038:                    .forID("Europe/Paris");
0039:            private static final Chronology COPTIC_PARIS = CopticChronology
0040:                    .getInstance(PARIS);
0041:
0042:            //private static final DateTimeZone PARIS = DateTimeZone.forID("Europe/Paris");
0043:            private static final DateTimeZone LONDON = DateTimeZone
0044:                    .forID("Europe/London");
0045:
0046:            long y2002days = 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365
0047:                    + 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365
0048:                    + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365
0049:                    + 365 + 365 + 366 + 365;
0050:            long y2003days = 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365
0051:                    + 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365
0052:                    + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365
0053:                    + 365 + 365 + 366 + 365 + 365;
0054:
0055:            // 2002-06-09
0056:            private long TEST_TIME_NOW = (y2002days + 31L + 28L + 31L + 30L
0057:                    + 31L + 9L - 1L)
0058:                    * DateTimeConstants.MILLIS_PER_DAY;
0059:
0060:            // 2002-04-05 Fri
0061:            private long TEST_TIME1 = (y2002days + 31L + 28L + 31L + 5L - 1L)
0062:                    * DateTimeConstants.MILLIS_PER_DAY + 12L
0063:                    * DateTimeConstants.MILLIS_PER_HOUR + 24L
0064:                    * DateTimeConstants.MILLIS_PER_MINUTE;
0065:
0066:            // 2003-05-06 Tue
0067:            private long TEST_TIME2 = (y2003days + 31L + 28L + 31L + 30L + 6L - 1L)
0068:                    * DateTimeConstants.MILLIS_PER_DAY
0069:                    + 14L
0070:                    * DateTimeConstants.MILLIS_PER_HOUR
0071:                    + 28L
0072:                    * DateTimeConstants.MILLIS_PER_MINUTE;
0073:
0074:            private DateTimeZone zone = null;
0075:            private Locale locale = null;
0076:
0077:            public static void main(String[] args) {
0078:                junit.textui.TestRunner.run(suite());
0079:            }
0080:
0081:            public static TestSuite suite() {
0082:                return new TestSuite(TestDateTime_Properties.class);
0083:            }
0084:
0085:            public TestDateTime_Properties(String name) {
0086:                super (name);
0087:            }
0088:
0089:            protected void setUp() throws Exception {
0090:                DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
0091:                zone = DateTimeZone.getDefault();
0092:                locale = Locale.getDefault();
0093:                DateTimeZone.setDefault(LONDON);
0094:                Locale.setDefault(Locale.UK);
0095:            }
0096:
0097:            protected void tearDown() throws Exception {
0098:                DateTimeUtils.setCurrentMillisSystem();
0099:                DateTimeZone.setDefault(zone);
0100:                Locale.setDefault(locale);
0101:                zone = null;
0102:            }
0103:
0104:            //-----------------------------------------------------------------------
0105:            public void testTest() {
0106:                assertEquals("2002-06-09T00:00:00.000Z", new Instant(
0107:                        TEST_TIME_NOW).toString());
0108:                assertEquals("2002-04-05T12:24:00.000Z",
0109:                        new Instant(TEST_TIME1).toString());
0110:                assertEquals("2003-05-06T14:28:00.000Z",
0111:                        new Instant(TEST_TIME2).toString());
0112:            }
0113:
0114:            //-----------------------------------------------------------------------
0115:            public void testPropertyGetEra() {
0116:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0117:                assertSame(test.getChronology().era(), test.era().getField());
0118:                assertEquals("era", test.era().getName());
0119:                assertEquals("Property[era]", test.era().toString());
0120:                assertSame(test, test.era().getDateTime());
0121:                assertEquals(1, test.era().get());
0122:                assertEquals("1", test.era().getAsString());
0123:                assertEquals("AD", test.era().getAsText());
0124:                assertEquals("AD", test.era().getField().getAsText(1,
0125:                        Locale.ENGLISH));
0126:                assertEquals("ap. J.-C.", test.era().getAsText(Locale.FRENCH));
0127:                assertEquals("ap. J.-C.", test.era().getField().getAsText(1,
0128:                        Locale.FRENCH));
0129:                assertEquals("AD", test.era().getAsShortText());
0130:                assertEquals("AD", test.era().getField().getAsShortText(1,
0131:                        Locale.ENGLISH));
0132:                assertEquals("ap. J.-C.", test.era().getAsShortText(
0133:                        Locale.FRENCH));
0134:                assertEquals("ap. J.-C.", test.era().getField().getAsShortText(
0135:                        1, Locale.FRENCH));
0136:                assertEquals(test.getChronology().eras(), test.era()
0137:                        .getDurationField());
0138:                assertEquals(null, test.era().getRangeDurationField());
0139:                assertEquals(2, test.era().getMaximumTextLength(null));
0140:                assertEquals(9, test.era().getMaximumTextLength(Locale.FRENCH));
0141:                assertEquals(2, test.era().getMaximumShortTextLength(null));
0142:                assertEquals(9, test.era().getMaximumShortTextLength(
0143:                        Locale.FRENCH));
0144:            }
0145:
0146:            //-----------------------------------------------------------------------
0147:            public void testPropertyGetYearOfEra() {
0148:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0149:                assertSame(test.getChronology().yearOfEra(), test.yearOfEra()
0150:                        .getField());
0151:                assertEquals("yearOfEra", test.yearOfEra().getName());
0152:                assertEquals("Property[yearOfEra]", test.yearOfEra().toString());
0153:                assertSame(test, test.yearOfEra().getDateTime());
0154:                assertEquals(2004, test.yearOfEra().get());
0155:                assertEquals("2004", test.yearOfEra().getAsString());
0156:                assertEquals("2004", test.yearOfEra().getAsText());
0157:                assertEquals("2004", test.yearOfEra().getAsText(Locale.FRENCH));
0158:                assertEquals("2004", test.yearOfEra().getAsShortText());
0159:                assertEquals("2004", test.yearOfEra().getAsShortText(
0160:                        Locale.FRENCH));
0161:                assertEquals(test.getChronology().years(), test.yearOfEra()
0162:                        .getDurationField());
0163:                assertEquals(null, test.yearOfEra().getRangeDurationField());
0164:                assertEquals(9, test.yearOfEra().getMaximumTextLength(null));
0165:                assertEquals(9, test.yearOfEra()
0166:                        .getMaximumShortTextLength(null));
0167:            }
0168:
0169:            //-----------------------------------------------------------------------
0170:            public void testPropertyGetCenturyOfEra() {
0171:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0172:                assertSame(test.getChronology().centuryOfEra(), test
0173:                        .centuryOfEra().getField());
0174:                assertEquals("centuryOfEra", test.centuryOfEra().getName());
0175:                assertEquals("Property[centuryOfEra]", test.centuryOfEra()
0176:                        .toString());
0177:                assertSame(test, test.centuryOfEra().getDateTime());
0178:                assertEquals(20, test.centuryOfEra().get());
0179:                assertEquals("20", test.centuryOfEra().getAsString());
0180:                assertEquals("20", test.centuryOfEra().getAsText());
0181:                assertEquals("20", test.centuryOfEra().getAsText(Locale.FRENCH));
0182:                assertEquals("20", test.centuryOfEra().getAsShortText());
0183:                assertEquals("20", test.centuryOfEra().getAsShortText(
0184:                        Locale.FRENCH));
0185:                assertEquals(test.getChronology().centuries(), test
0186:                        .centuryOfEra().getDurationField());
0187:                assertEquals(null, test.centuryOfEra().getRangeDurationField());
0188:                assertEquals(7, test.centuryOfEra().getMaximumTextLength(null));
0189:                assertEquals(7, test.centuryOfEra().getMaximumShortTextLength(
0190:                        null));
0191:            }
0192:
0193:            //-----------------------------------------------------------------------
0194:            public void testPropertyGetYearOfCentury() {
0195:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0196:                assertSame(test.getChronology().yearOfCentury(), test
0197:                        .yearOfCentury().getField());
0198:                assertEquals("yearOfCentury", test.yearOfCentury().getName());
0199:                assertEquals("Property[yearOfCentury]", test.yearOfCentury()
0200:                        .toString());
0201:                assertSame(test, test.yearOfCentury().getDateTime());
0202:                assertEquals(4, test.yearOfCentury().get());
0203:                assertEquals("4", test.yearOfCentury().getAsString());
0204:                assertEquals("4", test.yearOfCentury().getAsText());
0205:                assertEquals("4", test.yearOfCentury().getAsText(Locale.FRENCH));
0206:                assertEquals("4", test.yearOfCentury().getAsShortText());
0207:                assertEquals("4", test.yearOfCentury().getAsShortText(
0208:                        Locale.FRENCH));
0209:                assertEquals(test.getChronology().years(), test.yearOfCentury()
0210:                        .getDurationField());
0211:                assertEquals(test.getChronology().centuries(), test
0212:                        .yearOfCentury().getRangeDurationField());
0213:                assertEquals(2, test.yearOfCentury().getMaximumTextLength(null));
0214:                assertEquals(2, test.yearOfCentury().getMaximumShortTextLength(
0215:                        null));
0216:            }
0217:
0218:            //-----------------------------------------------------------------------
0219:            public void testPropertyGetWeekyear() {
0220:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0221:                assertSame(test.getChronology().weekyear(), test.weekyear()
0222:                        .getField());
0223:                assertEquals("weekyear", test.weekyear().getName());
0224:                assertEquals("Property[weekyear]", test.weekyear().toString());
0225:                assertSame(test, test.weekyear().getDateTime());
0226:                assertEquals(2004, test.weekyear().get());
0227:                assertEquals("2004", test.weekyear().getAsString());
0228:                assertEquals("2004", test.weekyear().getAsText());
0229:                assertEquals("2004", test.weekyear().getAsText(Locale.FRENCH));
0230:                assertEquals("2004", test.weekyear().getAsShortText());
0231:                assertEquals("2004", test.weekyear().getAsShortText(
0232:                        Locale.FRENCH));
0233:                assertEquals(test.getChronology().weekyears(), test.weekyear()
0234:                        .getDurationField());
0235:                assertEquals(null, test.weekyear().getRangeDurationField());
0236:                assertEquals(9, test.weekyear().getMaximumTextLength(null));
0237:                assertEquals(9, test.weekyear().getMaximumShortTextLength(null));
0238:            }
0239:
0240:            //-----------------------------------------------------------------------
0241:            public void testPropertyGetYear() {
0242:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0243:                assertSame(test.getChronology().year(), test.year().getField());
0244:                assertEquals("year", test.year().getName());
0245:                assertEquals("Property[year]", test.year().toString());
0246:                assertSame(test, test.year().getDateTime());
0247:                assertEquals(2004, test.year().get());
0248:                assertEquals("2004", test.year().getAsString());
0249:                assertEquals("2004", test.year().getAsText());
0250:                assertEquals("2004", test.year().getAsText(Locale.FRENCH));
0251:                assertEquals("2004", test.year().getAsShortText());
0252:                assertEquals("2004", test.year().getAsShortText(Locale.FRENCH));
0253:                assertEquals(test.getChronology().years(), test.year()
0254:                        .getDurationField());
0255:                assertEquals(null, test.year().getRangeDurationField());
0256:                assertEquals(9, test.year().getMaximumTextLength(null));
0257:                assertEquals(9, test.year().getMaximumShortTextLength(null));
0258:                assertEquals(-292275054, test.year().getMinimumValue());
0259:                assertEquals(-292275054, test.year().getMinimumValueOverall());
0260:                assertEquals(292278993, test.year().getMaximumValue());
0261:                assertEquals(292278993, test.year().getMaximumValueOverall());
0262:            }
0263:
0264:            public void testPropertyLeapYear() {
0265:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0266:                assertEquals(true, test.year().isLeap());
0267:                assertEquals(1, test.year().getLeapAmount());
0268:                assertEquals(test.getChronology().days(), test.year()
0269:                        .getLeapDurationField());
0270:                test = new DateTime(2003, 6, 9, 0, 0, 0, 0);
0271:                assertEquals(false, test.year().isLeap());
0272:                assertEquals(0, test.year().getLeapAmount());
0273:                assertEquals(test.getChronology().days(), test.year()
0274:                        .getLeapDurationField());
0275:            }
0276:
0277:            public void testPropertyAddYear() {
0278:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0279:                DateTime copy = test.year().addToCopy(9);
0280:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0281:                assertEquals("2013-06-09T00:00:00.000+01:00", copy.toString());
0282:
0283:                copy = test.year().addToCopy(0);
0284:                assertEquals("2004-06-09T00:00:00.000+01:00", copy.toString());
0285:
0286:                copy = test.year().addToCopy(292277023 - 2004);
0287:                assertEquals(292277023, copy.getYear());
0288:
0289:                try {
0290:                    test.year().addToCopy(292278993 - 2004 + 1);
0291:                    fail();
0292:                } catch (IllegalArgumentException ex) {
0293:                }
0294:
0295:                copy = test.year().addToCopy(-2004);
0296:                assertEquals(0, copy.getYear());
0297:
0298:                copy = test.year().addToCopy(-2005);
0299:                assertEquals(-1, copy.getYear());
0300:
0301:                try {
0302:                    test.year().addToCopy(-292275054 - 2004 - 1);
0303:                    fail();
0304:                } catch (IllegalArgumentException ex) {
0305:                }
0306:            }
0307:
0308:            public void testPropertyAddWrapFieldYear() {
0309:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0310:                DateTime copy = test.year().addWrapFieldToCopy(9);
0311:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0312:                assertEquals("2013-06-09T00:00:00.000+01:00", copy.toString());
0313:
0314:                copy = test.year().addWrapFieldToCopy(0);
0315:                assertEquals(2004, copy.getYear());
0316:
0317:                copy = test.year().addWrapFieldToCopy(292278993 - 2004 + 1);
0318:                assertEquals(-292275054, copy.getYear());
0319:
0320:                copy = test.year().addWrapFieldToCopy(-292275054 - 2004 - 1);
0321:                assertEquals(292278993, copy.getYear());
0322:            }
0323:
0324:            public void testPropertySetYear() {
0325:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0326:                DateTime copy = test.year().setCopy(1960);
0327:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0328:                assertEquals("1960-06-09T00:00:00.000+01:00", copy.toString());
0329:            }
0330:
0331:            public void testPropertySetTextYear() {
0332:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0333:                DateTime copy = test.year().setCopy("1960");
0334:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0335:                assertEquals("1960-06-09T00:00:00.000+01:00", copy.toString());
0336:            }
0337:
0338:            public void testPropertyCompareToYear() {
0339:                DateTime test1 = new DateTime(TEST_TIME1);
0340:                DateTime test2 = new DateTime(TEST_TIME2);
0341:                assertEquals(true, test1.year().compareTo(test2) < 0);
0342:                assertEquals(true, test2.year().compareTo(test1) > 0);
0343:                assertEquals(true, test1.year().compareTo(test1) == 0);
0344:                try {
0345:                    test1.year().compareTo((ReadableInstant) null);
0346:                    fail();
0347:                } catch (IllegalArgumentException ex) {
0348:                }
0349:            }
0350:
0351:            public void testPropertyCompareToYear2() {
0352:                DateTime test1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0353:                YearMonthDay ymd1 = new YearMonthDay(2003, 6, 9);
0354:                YearMonthDay ymd2 = new YearMonthDay(2004, 6, 9);
0355:                YearMonthDay ymd3 = new YearMonthDay(2005, 6, 9);
0356:                assertEquals(true, test1.year().compareTo(ymd1) > 0);
0357:                assertEquals(true, test1.year().compareTo(ymd2) == 0);
0358:                assertEquals(true, test1.year().compareTo(ymd3) < 0);
0359:                try {
0360:                    test1.year().compareTo((ReadablePartial) null);
0361:                    fail();
0362:                } catch (IllegalArgumentException ex) {
0363:                }
0364:            }
0365:
0366:            public void testPropertyEqualsHashCodeYear() {
0367:                DateTime test1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0368:                assertEquals(true, test1.year().equals(test1.year()));
0369:                assertEquals(true, test1.year().equals(
0370:                        new DateTime(2004, 6, 9, 0, 0, 0, 0).year()));
0371:                assertEquals(false, test1.year().equals(
0372:                        new DateTime(2004, 6, 9, 0, 0, 0, 0).monthOfYear()));
0373:                assertEquals(false, test1.year().equals(
0374:                        new DateTime(2004, 6, 9, 0, 0, 0, 0, CopticChronology
0375:                                .getInstance()).year()));
0376:
0377:                assertEquals(true, test1.year().hashCode() == test1.year()
0378:                        .hashCode());
0379:                assertEquals(true, test1.year().hashCode() == new DateTime(
0380:                        2004, 6, 9, 0, 0, 0, 0).year().hashCode());
0381:                assertEquals(false, test1.year().hashCode() == new DateTime(
0382:                        2004, 6, 9, 0, 0, 0, 0).monthOfYear().hashCode());
0383:                assertEquals(false, test1.year().hashCode() == new DateTime(
0384:                        2004, 6, 9, 0, 0, 0, 0, CopticChronology.getInstance())
0385:                        .year().hashCode());
0386:            }
0387:
0388:            //-----------------------------------------------------------------------
0389:            public void testPropertyGetMonthOfYear() {
0390:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0391:                assertSame(test.getChronology().monthOfYear(), test
0392:                        .monthOfYear().getField());
0393:                assertEquals("monthOfYear", test.monthOfYear().getName());
0394:                assertEquals("Property[monthOfYear]", test.monthOfYear()
0395:                        .toString());
0396:                assertSame(test, test.monthOfYear().getDateTime());
0397:                assertEquals(6, test.monthOfYear().get());
0398:                assertEquals("6", test.monthOfYear().getAsString());
0399:                assertEquals("June", test.monthOfYear().getAsText());
0400:                assertEquals("June", test.monthOfYear().getField().getAsText(6,
0401:                        Locale.ENGLISH));
0402:                assertEquals("juin", test.monthOfYear()
0403:                        .getAsText(Locale.FRENCH));
0404:                assertEquals("juin", test.monthOfYear().getField().getAsText(6,
0405:                        Locale.FRENCH));
0406:                assertEquals("Jun", test.monthOfYear().getAsShortText());
0407:                assertEquals("Jun", test.monthOfYear().getField()
0408:                        .getAsShortText(6, Locale.ENGLISH));
0409:                assertEquals("juin", test.monthOfYear().getAsShortText(
0410:                        Locale.FRENCH));
0411:                assertEquals("juin", test.monthOfYear().getField()
0412:                        .getAsShortText(6, Locale.FRENCH));
0413:                assertEquals(test.getChronology().months(), test.monthOfYear()
0414:                        .getDurationField());
0415:                assertEquals(test.getChronology().years(), test.monthOfYear()
0416:                        .getRangeDurationField());
0417:                assertEquals(9, test.monthOfYear().getMaximumTextLength(null));
0418:                assertEquals(3, test.monthOfYear().getMaximumShortTextLength(
0419:                        null));
0420:                test = new DateTime(2004, 7, 9, 0, 0, 0, 0);
0421:                assertEquals("juillet", test.monthOfYear().getAsText(
0422:                        Locale.FRENCH));
0423:                assertEquals("juillet", test.monthOfYear().getField()
0424:                        .getAsText(7, Locale.FRENCH));
0425:                assertEquals("juil.", test.monthOfYear().getAsShortText(
0426:                        Locale.FRENCH));
0427:                assertEquals("juil.", test.monthOfYear().getField()
0428:                        .getAsShortText(7, Locale.FRENCH));
0429:                assertEquals(1, test.monthOfYear().getMinimumValue());
0430:                assertEquals(1, test.monthOfYear().getMinimumValueOverall());
0431:                assertEquals(12, test.monthOfYear().getMaximumValue());
0432:                assertEquals(12, test.monthOfYear().getMaximumValueOverall());
0433:                assertEquals(1, test.monthOfYear().getMinimumValue());
0434:                assertEquals(1, test.monthOfYear().getMinimumValueOverall());
0435:                assertEquals(12, test.monthOfYear().getMaximumValue());
0436:                assertEquals(12, test.monthOfYear().getMaximumValueOverall());
0437:            }
0438:
0439:            public void testPropertyLeapMonthOfYear() {
0440:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0441:                assertEquals(false, test.monthOfYear().isLeap());
0442:                assertEquals(0, test.monthOfYear().getLeapAmount());
0443:                assertEquals(test.getChronology().days(), test.monthOfYear()
0444:                        .getLeapDurationField());
0445:
0446:                test = new DateTime(2004, 2, 9, 0, 0, 0, 0);
0447:                assertEquals(true, test.monthOfYear().isLeap());
0448:                assertEquals(1, test.monthOfYear().getLeapAmount());
0449:                assertEquals(test.getChronology().days(), test.monthOfYear()
0450:                        .getLeapDurationField());
0451:
0452:                test = new DateTime(2003, 6, 9, 0, 0, 0, 0);
0453:                assertEquals(false, test.monthOfYear().isLeap());
0454:                assertEquals(0, test.monthOfYear().getLeapAmount());
0455:                assertEquals(test.getChronology().days(), test.monthOfYear()
0456:                        .getLeapDurationField());
0457:
0458:                test = new DateTime(2003, 2, 9, 0, 0, 0, 0);
0459:                assertEquals(false, test.monthOfYear().isLeap());
0460:                assertEquals(0, test.monthOfYear().getLeapAmount());
0461:                assertEquals(test.getChronology().days(), test.monthOfYear()
0462:                        .getLeapDurationField());
0463:            }
0464:
0465:            public void testPropertyAddMonthOfYear() {
0466:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0467:                DateTime copy = test.monthOfYear().addToCopy(6);
0468:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0469:                assertEquals("2004-12-09T00:00:00.000Z", copy.toString());
0470:
0471:                copy = test.monthOfYear().addToCopy(7);
0472:                assertEquals("2005-01-09T00:00:00.000Z", copy.toString());
0473:
0474:                copy = test.monthOfYear().addToCopy(-5);
0475:                assertEquals("2004-01-09T00:00:00.000Z", copy.toString());
0476:
0477:                copy = test.monthOfYear().addToCopy(-6);
0478:                assertEquals("2003-12-09T00:00:00.000Z", copy.toString());
0479:
0480:                test = new DateTime(2004, 1, 31, 0, 0, 0, 0);
0481:                copy = test.monthOfYear().addToCopy(1);
0482:                assertEquals("2004-01-31T00:00:00.000Z", test.toString());
0483:                assertEquals("2004-02-29T00:00:00.000Z", copy.toString());
0484:
0485:                copy = test.monthOfYear().addToCopy(2);
0486:                assertEquals("2004-03-31T00:00:00.000+01:00", copy.toString());
0487:
0488:                copy = test.monthOfYear().addToCopy(3);
0489:                assertEquals("2004-04-30T00:00:00.000+01:00", copy.toString());
0490:
0491:                test = new DateTime(2003, 1, 31, 0, 0, 0, 0);
0492:                copy = test.monthOfYear().addToCopy(1);
0493:                assertEquals("2003-02-28T00:00:00.000Z", copy.toString());
0494:            }
0495:
0496:            public void testPropertyAddWrapFieldMonthOfYear() {
0497:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0498:                DateTime copy = test.monthOfYear().addWrapFieldToCopy(4);
0499:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0500:                assertEquals("2004-10-09T00:00:00.000+01:00", copy.toString());
0501:
0502:                copy = test.monthOfYear().addWrapFieldToCopy(8);
0503:                assertEquals("2004-02-09T00:00:00.000Z", copy.toString());
0504:
0505:                copy = test.monthOfYear().addWrapFieldToCopy(-8);
0506:                assertEquals("2004-10-09T00:00:00.000+01:00", copy.toString());
0507:
0508:                test = new DateTime(2004, 1, 31, 0, 0, 0, 0);
0509:                copy = test.monthOfYear().addWrapFieldToCopy(1);
0510:                assertEquals("2004-01-31T00:00:00.000Z", test.toString());
0511:                assertEquals("2004-02-29T00:00:00.000Z", copy.toString());
0512:
0513:                copy = test.monthOfYear().addWrapFieldToCopy(2);
0514:                assertEquals("2004-03-31T00:00:00.000+01:00", copy.toString());
0515:
0516:                copy = test.monthOfYear().addWrapFieldToCopy(3);
0517:                assertEquals("2004-04-30T00:00:00.000+01:00", copy.toString());
0518:
0519:                test = new DateTime(2005, 1, 31, 0, 0, 0, 0);
0520:                copy = test.monthOfYear().addWrapFieldToCopy(1);
0521:                assertEquals("2005-01-31T00:00:00.000Z", test.toString());
0522:                assertEquals("2005-02-28T00:00:00.000Z", copy.toString());
0523:            }
0524:
0525:            public void testPropertySetMonthOfYear() {
0526:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0527:                DateTime copy = test.monthOfYear().setCopy(12);
0528:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0529:                assertEquals("2004-12-09T00:00:00.000Z", copy.toString());
0530:
0531:                test = new DateTime(2004, 1, 31, 0, 0, 0, 0);
0532:                copy = test.monthOfYear().setCopy(2);
0533:                assertEquals("2004-02-29T00:00:00.000Z", copy.toString());
0534:
0535:                try {
0536:                    test.monthOfYear().setCopy(13);
0537:                    fail();
0538:                } catch (IllegalArgumentException ex) {
0539:                }
0540:                try {
0541:                    test.monthOfYear().setCopy(0);
0542:                    fail();
0543:                } catch (IllegalArgumentException ex) {
0544:                }
0545:            }
0546:
0547:            public void testPropertySetTextMonthOfYear() {
0548:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0549:                DateTime copy = test.monthOfYear().setCopy("12");
0550:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0551:                assertEquals("2004-12-09T00:00:00.000Z", copy.toString());
0552:
0553:                copy = test.monthOfYear().setCopy("December");
0554:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0555:                assertEquals("2004-12-09T00:00:00.000Z", copy.toString());
0556:
0557:                copy = test.monthOfYear().setCopy("Dec");
0558:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0559:                assertEquals("2004-12-09T00:00:00.000Z", copy.toString());
0560:            }
0561:
0562:            public void testPropertyCompareToMonthOfYear() {
0563:                DateTime test1 = new DateTime(TEST_TIME1);
0564:                DateTime test2 = new DateTime(TEST_TIME2);
0565:                assertEquals(true, test1.monthOfYear().compareTo(test2) < 0);
0566:                assertEquals(true, test2.monthOfYear().compareTo(test1) > 0);
0567:                assertEquals(true, test1.monthOfYear().compareTo(test1) == 0);
0568:                try {
0569:                    test1.monthOfYear().compareTo((ReadableInstant) null);
0570:                    fail();
0571:                } catch (IllegalArgumentException ex) {
0572:                }
0573:
0574:                DateTime dt1 = new DateTime(TEST_TIME1);
0575:                DateTime dt2 = new DateTime(TEST_TIME2);
0576:                assertEquals(true, test1.monthOfYear().compareTo(dt2) < 0);
0577:                assertEquals(true, test2.monthOfYear().compareTo(dt1) > 0);
0578:                assertEquals(true, test1.monthOfYear().compareTo(dt1) == 0);
0579:                try {
0580:                    test1.monthOfYear().compareTo((ReadableInstant) null);
0581:                    fail();
0582:                } catch (IllegalArgumentException ex) {
0583:                }
0584:            }
0585:
0586:            //-----------------------------------------------------------------------
0587:            public void testPropertyGetDayOfMonth() {
0588:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0589:                assertSame(test.getChronology().dayOfMonth(), test.dayOfMonth()
0590:                        .getField());
0591:                assertEquals("dayOfMonth", test.dayOfMonth().getName());
0592:                assertEquals("Property[dayOfMonth]", test.dayOfMonth()
0593:                        .toString());
0594:                assertSame(test, test.dayOfMonth().getDateTime());
0595:                assertEquals(9, test.dayOfMonth().get());
0596:                assertEquals("9", test.dayOfMonth().getAsString());
0597:                assertEquals("9", test.dayOfMonth().getAsText());
0598:                assertEquals("9", test.dayOfMonth().getAsText(Locale.FRENCH));
0599:                assertEquals("9", test.dayOfMonth().getAsShortText());
0600:                assertEquals("9", test.dayOfMonth().getAsShortText(
0601:                        Locale.FRENCH));
0602:                assertEquals(test.getChronology().days(), test.dayOfMonth()
0603:                        .getDurationField());
0604:                assertEquals(test.getChronology().months(), test.dayOfMonth()
0605:                        .getRangeDurationField());
0606:                assertEquals(2, test.dayOfMonth().getMaximumTextLength(null));
0607:                assertEquals(2, test.dayOfMonth().getMaximumShortTextLength(
0608:                        null));
0609:                assertEquals(1, test.dayOfMonth().getMinimumValue());
0610:                assertEquals(1, test.dayOfMonth().getMinimumValueOverall());
0611:                assertEquals(30, test.dayOfMonth().getMaximumValue());
0612:                assertEquals(31, test.dayOfMonth().getMaximumValueOverall());
0613:                assertEquals(false, test.dayOfMonth().isLeap());
0614:                assertEquals(0, test.dayOfMonth().getLeapAmount());
0615:                assertEquals(null, test.dayOfMonth().getLeapDurationField());
0616:            }
0617:
0618:            public void testPropertyGetMaxMinValuesDayOfMonth() {
0619:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0620:                assertEquals(1, test.dayOfMonth().getMinimumValue());
0621:                assertEquals(1, test.dayOfMonth().getMinimumValueOverall());
0622:                assertEquals(30, test.dayOfMonth().getMaximumValue());
0623:                assertEquals(31, test.dayOfMonth().getMaximumValueOverall());
0624:                test = new DateTime(2004, 7, 9, 0, 0, 0, 0);
0625:                assertEquals(31, test.dayOfMonth().getMaximumValue());
0626:                test = new DateTime(2004, 2, 9, 0, 0, 0, 0);
0627:                assertEquals(29, test.dayOfMonth().getMaximumValue());
0628:                test = new DateTime(2003, 2, 9, 0, 0, 0, 0);
0629:                assertEquals(28, test.dayOfMonth().getMaximumValue());
0630:            }
0631:
0632:            public void testPropertyAddDayOfMonth() {
0633:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0634:                DateTime copy = test.dayOfMonth().addToCopy(9);
0635:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0636:                assertEquals("2004-06-18T00:00:00.000+01:00", copy.toString());
0637:
0638:                copy = test.dayOfMonth().addToCopy(21);
0639:                assertEquals("2004-06-30T00:00:00.000+01:00", copy.toString());
0640:
0641:                copy = test.dayOfMonth().addToCopy(22);
0642:                assertEquals("2004-07-01T00:00:00.000+01:00", copy.toString());
0643:
0644:                copy = test.dayOfMonth().addToCopy(22 + 30);
0645:                assertEquals("2004-07-31T00:00:00.000+01:00", copy.toString());
0646:
0647:                copy = test.dayOfMonth().addToCopy(22 + 31);
0648:                assertEquals("2004-08-01T00:00:00.000+01:00", copy.toString());
0649:
0650:                copy = test.dayOfMonth().addToCopy(
0651:                        21 + 31 + 31 + 30 + 31 + 30 + 31);
0652:                assertEquals("2004-12-31T00:00:00.000Z", copy.toString());
0653:
0654:                copy = test.dayOfMonth().addToCopy(
0655:                        22 + 31 + 31 + 30 + 31 + 30 + 31);
0656:                assertEquals("2005-01-01T00:00:00.000Z", copy.toString());
0657:
0658:                copy = test.dayOfMonth().addToCopy(-8);
0659:                assertEquals("2004-06-01T00:00:00.000+01:00", copy.toString());
0660:
0661:                copy = test.dayOfMonth().addToCopy(-9);
0662:                assertEquals("2004-05-31T00:00:00.000+01:00", copy.toString());
0663:
0664:                copy = test.dayOfMonth().addToCopy(-8 - 31 - 30 - 31 - 29 - 31);
0665:                assertEquals("2004-01-01T00:00:00.000Z", copy.toString());
0666:
0667:                copy = test.dayOfMonth().addToCopy(-9 - 31 - 30 - 31 - 29 - 31);
0668:                assertEquals("2003-12-31T00:00:00.000Z", copy.toString());
0669:            }
0670:
0671:            public void testPropertyAddWrapFieldDayOfMonth() {
0672:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0673:                DateTime copy = test.dayOfMonth().addWrapFieldToCopy(21);
0674:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0675:                assertEquals("2004-06-30T00:00:00.000+01:00", copy.toString());
0676:
0677:                copy = test.dayOfMonth().addWrapFieldToCopy(22);
0678:                assertEquals("2004-06-01T00:00:00.000+01:00", copy.toString());
0679:
0680:                copy = test.dayOfMonth().addWrapFieldToCopy(-12);
0681:                assertEquals("2004-06-27T00:00:00.000+01:00", copy.toString());
0682:
0683:                test = new DateTime(2004, 7, 9, 0, 0, 0, 0);
0684:                copy = test.dayOfMonth().addWrapFieldToCopy(21);
0685:                assertEquals("2004-07-30T00:00:00.000+01:00", copy.toString());
0686:
0687:                copy = test.dayOfMonth().addWrapFieldToCopy(22);
0688:                assertEquals("2004-07-31T00:00:00.000+01:00", copy.toString());
0689:
0690:                copy = test.dayOfMonth().addWrapFieldToCopy(23);
0691:                assertEquals("2004-07-01T00:00:00.000+01:00", copy.toString());
0692:
0693:                copy = test.dayOfMonth().addWrapFieldToCopy(-12);
0694:                assertEquals("2004-07-28T00:00:00.000+01:00", copy.toString());
0695:            }
0696:
0697:            public void testPropertySetDayOfMonth() {
0698:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0699:                DateTime copy = test.dayOfMonth().setCopy(12);
0700:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0701:                assertEquals("2004-06-12T00:00:00.000+01:00", copy.toString());
0702:
0703:                try {
0704:                    test.dayOfMonth().setCopy(31);
0705:                    fail();
0706:                } catch (IllegalArgumentException ex) {
0707:                }
0708:                try {
0709:                    test.dayOfMonth().setCopy(0);
0710:                    fail();
0711:                } catch (IllegalArgumentException ex) {
0712:                }
0713:            }
0714:
0715:            public void testPropertySetTextDayOfMonth() {
0716:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0717:                DateTime copy = test.dayOfMonth().setCopy("12");
0718:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0719:                assertEquals("2004-06-12T00:00:00.000+01:00", copy.toString());
0720:            }
0721:
0722:            public void testPropertyWithMaximumValueDayOfMonth() {
0723:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0724:                DateTime copy = test.dayOfMonth().withMaximumValue();
0725:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0726:                assertEquals("2004-06-30T00:00:00.000+01:00", copy.toString());
0727:            }
0728:
0729:            public void testPropertyWithMinimumValueDayOfMonth() {
0730:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0731:                DateTime copy = test.dayOfMonth().withMinimumValue();
0732:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0733:                assertEquals("2004-06-01T00:00:00.000+01:00", copy.toString());
0734:            }
0735:
0736:            public void testPropertyCompareToDayOfMonth() {
0737:                DateTime test1 = new DateTime(TEST_TIME1);
0738:                DateTime test2 = new DateTime(TEST_TIME2);
0739:                assertEquals(true, test1.dayOfMonth().compareTo(test2) < 0);
0740:                assertEquals(true, test2.dayOfMonth().compareTo(test1) > 0);
0741:                assertEquals(true, test1.dayOfMonth().compareTo(test1) == 0);
0742:                try {
0743:                    test1.dayOfMonth().compareTo((ReadableInstant) null);
0744:                    fail();
0745:                } catch (IllegalArgumentException ex) {
0746:                }
0747:
0748:                DateTime dt1 = new DateTime(TEST_TIME1);
0749:                DateTime dt2 = new DateTime(TEST_TIME2);
0750:                assertEquals(true, test1.dayOfMonth().compareTo(dt2) < 0);
0751:                assertEquals(true, test2.dayOfMonth().compareTo(dt1) > 0);
0752:                assertEquals(true, test1.dayOfMonth().compareTo(dt1) == 0);
0753:                try {
0754:                    test1.dayOfMonth().compareTo((ReadableInstant) null);
0755:                    fail();
0756:                } catch (IllegalArgumentException ex) {
0757:                }
0758:            }
0759:
0760:            //-----------------------------------------------------------------------
0761:            public void testPropertyGetDayOfYear() {
0762:                // 31+29+31+30+31+9 = 161
0763:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0764:                assertSame(test.getChronology().dayOfYear(), test.dayOfYear()
0765:                        .getField());
0766:                assertEquals("dayOfYear", test.dayOfYear().getName());
0767:                assertEquals("Property[dayOfYear]", test.dayOfYear().toString());
0768:                assertSame(test, test.dayOfYear().getDateTime());
0769:                assertEquals(161, test.dayOfYear().get());
0770:                assertEquals("161", test.dayOfYear().getAsString());
0771:                assertEquals("161", test.dayOfYear().getAsText());
0772:                assertEquals("161", test.dayOfYear().getAsText(Locale.FRENCH));
0773:                assertEquals("161", test.dayOfYear().getAsShortText());
0774:                assertEquals("161", test.dayOfYear().getAsShortText(
0775:                        Locale.FRENCH));
0776:                assertEquals(test.getChronology().days(), test.dayOfYear()
0777:                        .getDurationField());
0778:                assertEquals(test.getChronology().years(), test.dayOfYear()
0779:                        .getRangeDurationField());
0780:                assertEquals(3, test.dayOfYear().getMaximumTextLength(null));
0781:                assertEquals(3, test.dayOfYear()
0782:                        .getMaximumShortTextLength(null));
0783:                assertEquals(false, test.dayOfYear().isLeap());
0784:                assertEquals(0, test.dayOfYear().getLeapAmount());
0785:                assertEquals(null, test.dayOfYear().getLeapDurationField());
0786:            }
0787:
0788:            public void testPropertyGetMaxMinValuesDayOfYear() {
0789:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0790:                assertEquals(1, test.dayOfYear().getMinimumValue());
0791:                assertEquals(1, test.dayOfYear().getMinimumValueOverall());
0792:                assertEquals(366, test.dayOfYear().getMaximumValue());
0793:                assertEquals(366, test.dayOfYear().getMaximumValueOverall());
0794:                test = new DateTime(2002, 6, 9, 0, 0, 0, 0);
0795:                assertEquals(365, test.dayOfYear().getMaximumValue());
0796:                assertEquals(366, test.dayOfYear().getMaximumValueOverall());
0797:            }
0798:
0799:            public void testPropertyAddDayOfYear() {
0800:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0801:                DateTime copy = test.dayOfYear().addToCopy(9);
0802:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0803:                assertEquals("2004-06-18T00:00:00.000+01:00", copy.toString());
0804:
0805:                copy = test.dayOfYear().addToCopy(21);
0806:                assertEquals("2004-06-30T00:00:00.000+01:00", copy.toString());
0807:
0808:                copy = test.dayOfYear().addToCopy(22);
0809:                assertEquals("2004-07-01T00:00:00.000+01:00", copy.toString());
0810:
0811:                copy = test.dayOfYear().addToCopy(
0812:                        21 + 31 + 31 + 30 + 31 + 30 + 31);
0813:                assertEquals("2004-12-31T00:00:00.000Z", copy.toString());
0814:
0815:                copy = test.dayOfYear().addToCopy(
0816:                        22 + 31 + 31 + 30 + 31 + 30 + 31);
0817:                assertEquals("2005-01-01T00:00:00.000Z", copy.toString());
0818:
0819:                copy = test.dayOfYear().addToCopy(-8);
0820:                assertEquals("2004-06-01T00:00:00.000+01:00", copy.toString());
0821:
0822:                copy = test.dayOfYear().addToCopy(-9);
0823:                assertEquals("2004-05-31T00:00:00.000+01:00", copy.toString());
0824:
0825:                copy = test.dayOfYear().addToCopy(-8 - 31 - 30 - 31 - 29 - 31);
0826:                assertEquals("2004-01-01T00:00:00.000Z", copy.toString());
0827:
0828:                copy = test.dayOfYear().addToCopy(-9 - 31 - 30 - 31 - 29 - 31);
0829:                assertEquals("2003-12-31T00:00:00.000Z", copy.toString());
0830:            }
0831:
0832:            public void testPropertyAddWrapFieldDayOfYear() {
0833:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0834:                DateTime copy = test.dayOfYear().addWrapFieldToCopy(21);
0835:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0836:                assertEquals("2004-06-30T00:00:00.000+01:00", copy.toString());
0837:
0838:                copy = test.dayOfYear().addWrapFieldToCopy(22);
0839:                assertEquals("2004-07-01T00:00:00.000+01:00", copy.toString());
0840:
0841:                copy = test.dayOfYear().addWrapFieldToCopy(-12);
0842:                assertEquals("2004-05-28T00:00:00.000+01:00", copy.toString());
0843:
0844:                copy = test.dayOfYear().addWrapFieldToCopy(205);
0845:                assertEquals("2004-12-31T00:00:00.000Z", copy.toString());
0846:
0847:                copy = test.dayOfYear().addWrapFieldToCopy(206);
0848:                assertEquals("2004-01-01T00:00:00.000Z", copy.toString());
0849:
0850:                copy = test.dayOfYear().addWrapFieldToCopy(-160);
0851:                assertEquals("2004-01-01T00:00:00.000Z", copy.toString());
0852:
0853:                copy = test.dayOfYear().addWrapFieldToCopy(-161);
0854:                assertEquals("2004-12-31T00:00:00.000Z", copy.toString());
0855:            }
0856:
0857:            public void testPropertySetDayOfYear() {
0858:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0859:                DateTime copy = test.dayOfYear().setCopy(12);
0860:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0861:                assertEquals("2004-01-12T00:00:00.000Z", copy.toString());
0862:
0863:                try {
0864:                    test.dayOfYear().setCopy(367);
0865:                    fail();
0866:                } catch (IllegalArgumentException ex) {
0867:                }
0868:                try {
0869:                    test.dayOfYear().setCopy(0);
0870:                    fail();
0871:                } catch (IllegalArgumentException ex) {
0872:                }
0873:            }
0874:
0875:            public void testPropertySetTextDayOfYear() {
0876:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0877:                DateTime copy = test.dayOfYear().setCopy("12");
0878:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
0879:                assertEquals("2004-01-12T00:00:00.000Z", copy.toString());
0880:            }
0881:
0882:            public void testPropertyCompareToDayOfYear() {
0883:                DateTime test1 = new DateTime(TEST_TIME1);
0884:                DateTime test2 = new DateTime(TEST_TIME2);
0885:                assertEquals(true, test1.dayOfYear().compareTo(test2) < 0);
0886:                assertEquals(true, test2.dayOfYear().compareTo(test1) > 0);
0887:                assertEquals(true, test1.dayOfYear().compareTo(test1) == 0);
0888:                try {
0889:                    test1.dayOfYear().compareTo((ReadableInstant) null);
0890:                    fail();
0891:                } catch (IllegalArgumentException ex) {
0892:                }
0893:
0894:                DateTime dt1 = new DateTime(TEST_TIME1);
0895:                DateTime dt2 = new DateTime(TEST_TIME2);
0896:                assertEquals(true, test1.dayOfYear().compareTo(dt2) < 0);
0897:                assertEquals(true, test2.dayOfYear().compareTo(dt1) > 0);
0898:                assertEquals(true, test1.dayOfYear().compareTo(dt1) == 0);
0899:                try {
0900:                    test1.dayOfYear().compareTo((ReadableInstant) null);
0901:                    fail();
0902:                } catch (IllegalArgumentException ex) {
0903:                }
0904:            }
0905:
0906:            //-----------------------------------------------------------------------
0907:            public void testPropertyGetWeekOfWeekyear() {
0908:                // 2002-01-01 = Thu
0909:                // 2002-12-31 = Thu (+364 days)
0910:                // 2003-12-30 = Thu (+364 days)
0911:                // 2004-01-03 = Mon             W1
0912:                // 2004-01-31 = Mon (+28 days)  W5
0913:                // 2004-02-28 = Mon (+28 days)  W9
0914:                // 2004-03-27 = Mon (+28 days)  W13
0915:                // 2004-04-24 = Mon (+28 days)  W17
0916:                // 2004-05-23 = Mon (+28 days)  W21
0917:                // 2004-06-05 = Mon (+14 days)  W23
0918:                // 2004-06-09 = Fri
0919:                // 2004-12-25 = Mon             W52
0920:                // 2005-01-01 = Mon             W1
0921:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0922:                assertSame(test.getChronology().weekOfWeekyear(), test
0923:                        .weekOfWeekyear().getField());
0924:                assertEquals("weekOfWeekyear", test.weekOfWeekyear().getName());
0925:                assertEquals("Property[weekOfWeekyear]", test.weekOfWeekyear()
0926:                        .toString());
0927:                assertSame(test, test.weekOfWeekyear().getDateTime());
0928:                assertEquals(24, test.weekOfWeekyear().get());
0929:                assertEquals("24", test.weekOfWeekyear().getAsString());
0930:                assertEquals("24", test.weekOfWeekyear().getAsText());
0931:                assertEquals("24", test.weekOfWeekyear().getAsText(
0932:                        Locale.FRENCH));
0933:                assertEquals("24", test.weekOfWeekyear().getAsShortText());
0934:                assertEquals("24", test.weekOfWeekyear().getAsShortText(
0935:                        Locale.FRENCH));
0936:                assertEquals(test.getChronology().weeks(), test
0937:                        .weekOfWeekyear().getDurationField());
0938:                assertEquals(test.getChronology().weekyears(), test
0939:                        .weekOfWeekyear().getRangeDurationField());
0940:                assertEquals(2, test.weekOfWeekyear()
0941:                        .getMaximumTextLength(null));
0942:                assertEquals(2, test.weekOfWeekyear()
0943:                        .getMaximumShortTextLength(null));
0944:                assertEquals(false, test.weekOfWeekyear().isLeap());
0945:                assertEquals(0, test.weekOfWeekyear().getLeapAmount());
0946:                assertEquals(null, test.weekOfWeekyear().getLeapDurationField());
0947:            }
0948:
0949:            public void testPropertyGetMaxMinValuesWeekOfWeekyear() {
0950:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
0951:                assertEquals(1, test.weekOfWeekyear().getMinimumValue());
0952:                assertEquals(1, test.weekOfWeekyear().getMinimumValueOverall());
0953:                assertEquals(53, test.weekOfWeekyear().getMaximumValue());
0954:                assertEquals(53, test.weekOfWeekyear().getMaximumValueOverall());
0955:                test = new DateTime(2005, 6, 9, 0, 0, 0, 0);
0956:                assertEquals(52, test.weekOfWeekyear().getMaximumValue());
0957:                assertEquals(53, test.weekOfWeekyear().getMaximumValueOverall());
0958:            }
0959:
0960:            public void testPropertyAddWeekOfWeekyear() {
0961:                DateTime test = new DateTime(2004, 6, 7, 0, 0, 0, 0);
0962:                DateTime copy = test.weekOfWeekyear().addToCopy(1);
0963:                assertEquals("2004-06-07T00:00:00.000+01:00", test.toString());
0964:                assertEquals("2004-06-14T00:00:00.000+01:00", copy.toString());
0965:
0966:                copy = test.weekOfWeekyear().addToCopy(29);
0967:                assertEquals("2004-12-27T00:00:00.000Z", copy.toString());
0968:
0969:                copy = test.weekOfWeekyear().addToCopy(30);
0970:                assertEquals("2005-01-03T00:00:00.000Z", copy.toString());
0971:
0972:                copy = test.weekOfWeekyear().addToCopy(-22);
0973:                assertEquals("2004-01-05T00:00:00.000Z", copy.toString());
0974:
0975:                copy = test.weekOfWeekyear().addToCopy(-23);
0976:                assertEquals("2003-12-29T00:00:00.000Z", copy.toString());
0977:            }
0978:
0979:            public void testPropertyAddWrapFieldWeekOfWeekyear() {
0980:                DateTime test = new DateTime(2004, 6, 7, 0, 0, 0, 0);
0981:                DateTime copy = test.weekOfWeekyear().addWrapFieldToCopy(1);
0982:                assertEquals("2004-06-07T00:00:00.000+01:00", test.toString());
0983:                assertEquals("2004-06-14T00:00:00.000+01:00", copy.toString());
0984:
0985:                copy = test.weekOfWeekyear().addWrapFieldToCopy(29);
0986:                assertEquals("2004-12-27T00:00:00.000Z", copy.toString());
0987:
0988:                copy = test.weekOfWeekyear().addWrapFieldToCopy(30);
0989:                assertEquals("2003-12-29T00:00:00.000Z", copy.toString());
0990:
0991:                copy = test.weekOfWeekyear().addWrapFieldToCopy(-23);
0992:                assertEquals("2003-12-29T00:00:00.000Z", copy.toString());
0993:            }
0994:
0995:            public void testPropertySetWeekOfWeekyear() {
0996:                DateTime test = new DateTime(2004, 6, 7, 0, 0, 0, 0);
0997:                DateTime copy = test.weekOfWeekyear().setCopy(4);
0998:                assertEquals("2004-06-07T00:00:00.000+01:00", test.toString());
0999:                assertEquals("2004-01-19T00:00:00.000Z", copy.toString());
1000:
1001:                try {
1002:                    test.weekOfWeekyear().setCopy(54);
1003:                    fail();
1004:                } catch (IllegalArgumentException ex) {
1005:                }
1006:                try {
1007:                    test.weekOfWeekyear().setCopy(0);
1008:                    fail();
1009:                } catch (IllegalArgumentException ex) {
1010:                }
1011:            }
1012:
1013:            public void testPropertySetTextWeekOfWeekyear() {
1014:                DateTime test = new DateTime(2004, 6, 7, 0, 0, 0, 0);
1015:                DateTime copy = test.weekOfWeekyear().setCopy("4");
1016:                assertEquals("2004-06-07T00:00:00.000+01:00", test.toString());
1017:                assertEquals("2004-01-19T00:00:00.000Z", copy.toString());
1018:            }
1019:
1020:            public void testPropertyCompareToWeekOfWeekyear() {
1021:                DateTime test1 = new DateTime(TEST_TIME1);
1022:                DateTime test2 = new DateTime(TEST_TIME2);
1023:                assertEquals(true, test1.weekOfWeekyear().compareTo(test2) < 0);
1024:                assertEquals(true, test2.weekOfWeekyear().compareTo(test1) > 0);
1025:                assertEquals(true, test1.weekOfWeekyear().compareTo(test1) == 0);
1026:                try {
1027:                    test1.weekOfWeekyear().compareTo((ReadableInstant) null);
1028:                    fail();
1029:                } catch (IllegalArgumentException ex) {
1030:                }
1031:
1032:                DateTime dt1 = new DateTime(TEST_TIME1);
1033:                DateTime dt2 = new DateTime(TEST_TIME2);
1034:                assertEquals(true, test1.weekOfWeekyear().compareTo(dt2) < 0);
1035:                assertEquals(true, test2.weekOfWeekyear().compareTo(dt1) > 0);
1036:                assertEquals(true, test1.weekOfWeekyear().compareTo(dt1) == 0);
1037:                try {
1038:                    test1.weekOfWeekyear().compareTo((ReadableInstant) null);
1039:                    fail();
1040:                } catch (IllegalArgumentException ex) {
1041:                }
1042:            }
1043:
1044:            //-----------------------------------------------------------------------
1045:            public void testPropertyGetDayOfWeek() {
1046:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
1047:                assertSame(test.getChronology().dayOfWeek(), test.dayOfWeek()
1048:                        .getField());
1049:                assertEquals("dayOfWeek", test.dayOfWeek().getName());
1050:                assertEquals("Property[dayOfWeek]", test.dayOfWeek().toString());
1051:                assertSame(test, test.dayOfWeek().getDateTime());
1052:                assertEquals(3, test.dayOfWeek().get());
1053:                assertEquals("3", test.dayOfWeek().getAsString());
1054:                assertEquals("Wednesday", test.dayOfWeek().getAsText());
1055:                assertEquals("Wednesday", test.dayOfWeek().getField()
1056:                        .getAsText(3, Locale.ENGLISH));
1057:                assertEquals("mercredi", test.dayOfWeek().getAsText(
1058:                        Locale.FRENCH));
1059:                assertEquals("mercredi", test.dayOfWeek().getField().getAsText(
1060:                        3, Locale.FRENCH));
1061:                assertEquals("Wed", test.dayOfWeek().getAsShortText());
1062:                assertEquals("Wed", test.dayOfWeek().getField().getAsShortText(
1063:                        3, Locale.ENGLISH));
1064:                assertEquals("mer.", test.dayOfWeek().getAsShortText(
1065:                        Locale.FRENCH));
1066:                assertEquals("mer.", test.dayOfWeek().getField()
1067:                        .getAsShortText(3, Locale.FRENCH));
1068:                assertEquals(test.getChronology().days(), test.dayOfWeek()
1069:                        .getDurationField());
1070:                assertEquals(test.getChronology().weeks(), test.dayOfWeek()
1071:                        .getRangeDurationField());
1072:                assertEquals(9, test.dayOfWeek().getMaximumTextLength(null));
1073:                assertEquals(8, test.dayOfWeek().getMaximumTextLength(
1074:                        Locale.FRENCH));
1075:                assertEquals(3, test.dayOfWeek()
1076:                        .getMaximumShortTextLength(null));
1077:                assertEquals(4, test.dayOfWeek().getMaximumShortTextLength(
1078:                        Locale.FRENCH));
1079:                assertEquals(1, test.dayOfWeek().getMinimumValue());
1080:                assertEquals(1, test.dayOfWeek().getMinimumValueOverall());
1081:                assertEquals(7, test.dayOfWeek().getMaximumValue());
1082:                assertEquals(7, test.dayOfWeek().getMaximumValueOverall());
1083:                assertEquals(false, test.dayOfWeek().isLeap());
1084:                assertEquals(0, test.dayOfWeek().getLeapAmount());
1085:                assertEquals(null, test.dayOfWeek().getLeapDurationField());
1086:            }
1087:
1088:            public void testPropertyAddDayOfWeek() {
1089:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
1090:                DateTime copy = test.dayOfWeek().addToCopy(1);
1091:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
1092:                assertEquals("2004-06-10T00:00:00.000+01:00", copy.toString());
1093:
1094:                copy = test.dayOfWeek().addToCopy(21);
1095:                assertEquals("2004-06-30T00:00:00.000+01:00", copy.toString());
1096:
1097:                copy = test.dayOfWeek().addToCopy(22);
1098:                assertEquals("2004-07-01T00:00:00.000+01:00", copy.toString());
1099:
1100:                copy = test.dayOfWeek().addToCopy(
1101:                        21 + 31 + 31 + 30 + 31 + 30 + 31);
1102:                assertEquals("2004-12-31T00:00:00.000Z", copy.toString());
1103:
1104:                copy = test.dayOfWeek().addToCopy(
1105:                        22 + 31 + 31 + 30 + 31 + 30 + 31);
1106:                assertEquals("2005-01-01T00:00:00.000Z", copy.toString());
1107:
1108:                copy = test.dayOfWeek().addToCopy(-8);
1109:                assertEquals("2004-06-01T00:00:00.000+01:00", copy.toString());
1110:
1111:                copy = test.dayOfWeek().addToCopy(-9);
1112:                assertEquals("2004-05-31T00:00:00.000+01:00", copy.toString());
1113:
1114:                copy = test.dayOfWeek().addToCopy(-8 - 31 - 30 - 31 - 29 - 31);
1115:                assertEquals("2004-01-01T00:00:00.000Z", copy.toString());
1116:
1117:                copy = test.dayOfWeek().addToCopy(-9 - 31 - 30 - 31 - 29 - 31);
1118:                assertEquals("2003-12-31T00:00:00.000Z", copy.toString());
1119:            }
1120:
1121:            public void testPropertyAddLongDayOfWeek() {
1122:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
1123:                DateTime copy = test.dayOfWeek().addToCopy(1L);
1124:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
1125:                assertEquals("2004-06-10T00:00:00.000+01:00", copy.toString());
1126:            }
1127:
1128:            public void testPropertyAddWrapFieldDayOfWeek() {
1129:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0); // Wed
1130:                DateTime copy = test.dayOfWeek().addWrapFieldToCopy(1);
1131:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
1132:                assertEquals("2004-06-10T00:00:00.000+01:00", copy.toString());
1133:
1134:                copy = test.dayOfWeek().addWrapFieldToCopy(5);
1135:                assertEquals("2004-06-07T00:00:00.000+01:00", copy.toString());
1136:
1137:                copy = test.dayOfWeek().addWrapFieldToCopy(-10);
1138:                assertEquals("2004-06-13T00:00:00.000+01:00", copy.toString());
1139:
1140:                test = new DateTime(2004, 6, 2, 0, 0, 0, 0);
1141:                copy = test.dayOfWeek().addWrapFieldToCopy(5);
1142:                assertEquals("2004-06-02T00:00:00.000+01:00", test.toString());
1143:                assertEquals("2004-05-31T00:00:00.000+01:00", copy.toString());
1144:            }
1145:
1146:            public void testPropertySetDayOfWeek() {
1147:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
1148:                DateTime copy = test.dayOfWeek().setCopy(4);
1149:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
1150:                assertEquals("2004-06-10T00:00:00.000+01:00", copy.toString());
1151:
1152:                try {
1153:                    test.dayOfWeek().setCopy(8);
1154:                    fail();
1155:                } catch (IllegalArgumentException ex) {
1156:                }
1157:                try {
1158:                    test.dayOfWeek().setCopy(0);
1159:                    fail();
1160:                } catch (IllegalArgumentException ex) {
1161:                }
1162:            }
1163:
1164:            public void testPropertySetTextDayOfWeek() {
1165:                DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
1166:                DateTime copy = test.dayOfWeek().setCopy("4");
1167:                assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
1168:                assertEquals("2004-06-10T00:00:00.000+01:00", copy.toString());
1169:                copy = test.dayOfWeek().setCopy("Mon");
1170:                assertEquals("2004-06-07T00:00:00.000+01:00", copy.toString());
1171:                copy = test.dayOfWeek().setCopy("Tuesday");
1172:                assertEquals("2004-06-08T00:00:00.000+01:00", copy.toString());
1173:                copy = test.dayOfWeek().setCopy("lundi", Locale.FRENCH);
1174:                assertEquals("2004-06-07T00:00:00.000+01:00", copy.toString());
1175:            }
1176:
1177:            public void testPropertyCompareToDayOfWeek() {
1178:                DateTime test1 = new DateTime(TEST_TIME1);
1179:                DateTime test2 = new DateTime(TEST_TIME2);
1180:                assertEquals(true, test2.dayOfWeek().compareTo(test1) < 0);
1181:                assertEquals(true, test1.dayOfWeek().compareTo(test2) > 0);
1182:                assertEquals(true, test1.dayOfWeek().compareTo(test1) == 0);
1183:                try {
1184:                    test1.dayOfWeek().compareTo((ReadableInstant) null);
1185:                    fail();
1186:                } catch (IllegalArgumentException ex) {
1187:                }
1188:
1189:                DateTime dt1 = new DateTime(TEST_TIME1);
1190:                DateTime dt2 = new DateTime(TEST_TIME2);
1191:                assertEquals(true, test2.dayOfWeek().compareTo(dt1) < 0);
1192:                assertEquals(true, test1.dayOfWeek().compareTo(dt2) > 0);
1193:                assertEquals(true, test1.dayOfWeek().compareTo(dt1) == 0);
1194:                try {
1195:                    test1.dayOfWeek().compareTo((ReadableInstant) null);
1196:                    fail();
1197:                } catch (IllegalArgumentException ex) {
1198:                }
1199:            }
1200:
1201:            //-----------------------------------------------------------------------
1202:            public void testPropertyGetHourOfDay() {
1203:                DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1204:                assertSame(test.getChronology().hourOfDay(), test.hourOfDay()
1205:                        .getField());
1206:                assertEquals("hourOfDay", test.hourOfDay().getName());
1207:                assertEquals("Property[hourOfDay]", test.hourOfDay().toString());
1208:                assertSame(test, test.hourOfDay().getDateTime());
1209:                assertEquals(13, test.hourOfDay().get());
1210:                assertEquals("13", test.hourOfDay().getAsString());
1211:                assertEquals("13", test.hourOfDay().getAsText());
1212:                assertEquals("13", test.hourOfDay().getAsText(Locale.FRENCH));
1213:                assertEquals("13", test.hourOfDay().getAsShortText());
1214:                assertEquals("13", test.hourOfDay().getAsShortText(
1215:                        Locale.FRENCH));
1216:                assertEquals(test.getChronology().hours(), test.hourOfDay()
1217:                        .getDurationField());
1218:                assertEquals(test.getChronology().days(), test.hourOfDay()
1219:                        .getRangeDurationField());
1220:                assertEquals(2, test.hourOfDay().getMaximumTextLength(null));
1221:                assertEquals(2, test.hourOfDay()
1222:                        .getMaximumShortTextLength(null));
1223:            }
1224:
1225:            public void testPropertyGetDifferenceHourOfDay() {
1226:                DateTime test1 = new DateTime(2004, 6, 9, 13, 30, 0, 0);
1227:                DateTime test2 = new DateTime(2004, 6, 9, 15, 30, 0, 0);
1228:                assertEquals(-2, test1.hourOfDay().getDifference(test2));
1229:                assertEquals(2, test2.hourOfDay().getDifference(test1));
1230:                assertEquals(-2L, test1.hourOfDay().getDifferenceAsLong(test2));
1231:                assertEquals(2L, test2.hourOfDay().getDifferenceAsLong(test1));
1232:
1233:                DateTime test = new DateTime(TEST_TIME_NOW
1234:                        + (13L * DateTimeConstants.MILLIS_PER_HOUR));
1235:                assertEquals(13, test.hourOfDay().getDifference(null));
1236:                assertEquals(13L, test.hourOfDay().getDifferenceAsLong(null));
1237:            }
1238:
1239:            public void testPropertyRoundFloorHourOfDay() {
1240:                DateTime test = new DateTime(2004, 6, 9, 13, 30, 0, 0);
1241:                DateTime copy = test.hourOfDay().roundFloorCopy();
1242:                assertEquals("2004-06-09T13:00:00.000+01:00", copy.toString());
1243:            }
1244:
1245:            public void testPropertyRoundCeilingHourOfDay() {
1246:                DateTime test = new DateTime(2004, 6, 9, 13, 30, 0, 0);
1247:                DateTime copy = test.hourOfDay().roundCeilingCopy();
1248:                assertEquals("2004-06-09T14:00:00.000+01:00", copy.toString());
1249:            }
1250:
1251:            public void testPropertyRoundHalfFloorHourOfDay() {
1252:                DateTime test = new DateTime(2004, 6, 9, 13, 30, 0, 0);
1253:                DateTime copy = test.hourOfDay().roundHalfFloorCopy();
1254:                assertEquals("2004-06-09T13:00:00.000+01:00", copy.toString());
1255:
1256:                test = new DateTime(2004, 6, 9, 13, 30, 0, 1);
1257:                copy = test.hourOfDay().roundHalfFloorCopy();
1258:                assertEquals("2004-06-09T14:00:00.000+01:00", copy.toString());
1259:
1260:                test = new DateTime(2004, 6, 9, 13, 29, 59, 999);
1261:                copy = test.hourOfDay().roundHalfFloorCopy();
1262:                assertEquals("2004-06-09T13:00:00.000+01:00", copy.toString());
1263:            }
1264:
1265:            public void testPropertyRoundHalfCeilingHourOfDay() {
1266:                DateTime test = new DateTime(2004, 6, 9, 13, 30, 0, 0);
1267:                DateTime copy = test.hourOfDay().roundHalfCeilingCopy();
1268:                assertEquals("2004-06-09T14:00:00.000+01:00", copy.toString());
1269:
1270:                test = new DateTime(2004, 6, 9, 13, 30, 0, 1);
1271:                copy = test.hourOfDay().roundHalfCeilingCopy();
1272:                assertEquals("2004-06-09T14:00:00.000+01:00", copy.toString());
1273:
1274:                test = new DateTime(2004, 6, 9, 13, 29, 59, 999);
1275:                copy = test.hourOfDay().roundHalfCeilingCopy();
1276:                assertEquals("2004-06-09T13:00:00.000+01:00", copy.toString());
1277:            }
1278:
1279:            public void testPropertyRoundHalfEvenHourOfDay() {
1280:                DateTime test = new DateTime(2004, 6, 9, 13, 30, 0, 0);
1281:                DateTime copy = test.hourOfDay().roundHalfEvenCopy();
1282:                assertEquals("2004-06-09T14:00:00.000+01:00", copy.toString());
1283:
1284:                test = new DateTime(2004, 6, 9, 14, 30, 0, 0);
1285:                copy = test.hourOfDay().roundHalfEvenCopy();
1286:                assertEquals("2004-06-09T14:00:00.000+01:00", copy.toString());
1287:
1288:                test = new DateTime(2004, 6, 9, 13, 30, 0, 1);
1289:                copy = test.hourOfDay().roundHalfEvenCopy();
1290:                assertEquals("2004-06-09T14:00:00.000+01:00", copy.toString());
1291:
1292:                test = new DateTime(2004, 6, 9, 13, 29, 59, 999);
1293:                copy = test.hourOfDay().roundHalfEvenCopy();
1294:                assertEquals("2004-06-09T13:00:00.000+01:00", copy.toString());
1295:            }
1296:
1297:            public void testPropertyRemainderHourOfDay() {
1298:                DateTime test = new DateTime(2004, 6, 9, 13, 30, 0, 0);
1299:                assertEquals(30L * DateTimeConstants.MILLIS_PER_MINUTE, test
1300:                        .hourOfDay().remainder());
1301:            }
1302:
1303:            //-----------------------------------------------------------------------
1304:            public void testPropertyGetMinuteOfHour() {
1305:                DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1306:                assertSame(test.getChronology().minuteOfHour(), test
1307:                        .minuteOfHour().getField());
1308:                assertEquals("minuteOfHour", test.minuteOfHour().getName());
1309:                assertEquals("Property[minuteOfHour]", test.minuteOfHour()
1310:                        .toString());
1311:                assertSame(test, test.minuteOfHour().getDateTime());
1312:                assertEquals(23, test.minuteOfHour().get());
1313:                assertEquals("23", test.minuteOfHour().getAsString());
1314:                assertEquals("23", test.minuteOfHour().getAsText());
1315:                assertEquals("23", test.minuteOfHour().getAsText(Locale.FRENCH));
1316:                assertEquals("23", test.minuteOfHour().getAsShortText());
1317:                assertEquals("23", test.minuteOfHour().getAsShortText(
1318:                        Locale.FRENCH));
1319:                assertEquals(test.getChronology().minutes(), test
1320:                        .minuteOfHour().getDurationField());
1321:                assertEquals(test.getChronology().hours(), test.minuteOfHour()
1322:                        .getRangeDurationField());
1323:                assertEquals(2, test.minuteOfHour().getMaximumTextLength(null));
1324:                assertEquals(2, test.minuteOfHour().getMaximumShortTextLength(
1325:                        null));
1326:            }
1327:
1328:            //-----------------------------------------------------------------------
1329:            public void testPropertyGetMinuteOfDay() {
1330:                DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1331:                assertSame(test.getChronology().minuteOfDay(), test
1332:                        .minuteOfDay().getField());
1333:                assertEquals("minuteOfDay", test.minuteOfDay().getName());
1334:                assertEquals("Property[minuteOfDay]", test.minuteOfDay()
1335:                        .toString());
1336:                assertSame(test, test.minuteOfDay().getDateTime());
1337:                assertEquals(803, test.minuteOfDay().get());
1338:                assertEquals("803", test.minuteOfDay().getAsString());
1339:                assertEquals("803", test.minuteOfDay().getAsText());
1340:                assertEquals("803", test.minuteOfDay().getAsText(Locale.FRENCH));
1341:                assertEquals("803", test.minuteOfDay().getAsShortText());
1342:                assertEquals("803", test.minuteOfDay().getAsShortText(
1343:                        Locale.FRENCH));
1344:                assertEquals(test.getChronology().minutes(), test.minuteOfDay()
1345:                        .getDurationField());
1346:                assertEquals(test.getChronology().days(), test.minuteOfDay()
1347:                        .getRangeDurationField());
1348:                assertEquals(4, test.minuteOfDay().getMaximumTextLength(null));
1349:                assertEquals(4, test.minuteOfDay().getMaximumShortTextLength(
1350:                        null));
1351:            }
1352:
1353:            //-----------------------------------------------------------------------
1354:            public void testPropertyGetSecondOfMinute() {
1355:                DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1356:                assertSame(test.getChronology().secondOfMinute(), test
1357:                        .secondOfMinute().getField());
1358:                assertEquals("secondOfMinute", test.secondOfMinute().getName());
1359:                assertEquals("Property[secondOfMinute]", test.secondOfMinute()
1360:                        .toString());
1361:                assertSame(test, test.secondOfMinute().getDateTime());
1362:                assertEquals(43, test.secondOfMinute().get());
1363:                assertEquals("43", test.secondOfMinute().getAsString());
1364:                assertEquals("43", test.secondOfMinute().getAsText());
1365:                assertEquals("43", test.secondOfMinute().getAsText(
1366:                        Locale.FRENCH));
1367:                assertEquals("43", test.secondOfMinute().getAsShortText());
1368:                assertEquals("43", test.secondOfMinute().getAsShortText(
1369:                        Locale.FRENCH));
1370:                assertEquals(test.getChronology().seconds(), test
1371:                        .secondOfMinute().getDurationField());
1372:                assertEquals(test.getChronology().minutes(), test
1373:                        .secondOfMinute().getRangeDurationField());
1374:                assertEquals(2, test.secondOfMinute()
1375:                        .getMaximumTextLength(null));
1376:                assertEquals(2, test.secondOfMinute()
1377:                        .getMaximumShortTextLength(null));
1378:            }
1379:
1380:            //-----------------------------------------------------------------------
1381:            public void testPropertyGetSecondOfDay() {
1382:                DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1383:                assertSame(test.getChronology().secondOfDay(), test
1384:                        .secondOfDay().getField());
1385:                assertEquals("secondOfDay", test.secondOfDay().getName());
1386:                assertEquals("Property[secondOfDay]", test.secondOfDay()
1387:                        .toString());
1388:                assertSame(test, test.secondOfDay().getDateTime());
1389:                assertEquals(48223, test.secondOfDay().get());
1390:                assertEquals("48223", test.secondOfDay().getAsString());
1391:                assertEquals("48223", test.secondOfDay().getAsText());
1392:                assertEquals("48223", test.secondOfDay().getAsText(
1393:                        Locale.FRENCH));
1394:                assertEquals("48223", test.secondOfDay().getAsShortText());
1395:                assertEquals("48223", test.secondOfDay().getAsShortText(
1396:                        Locale.FRENCH));
1397:                assertEquals(test.getChronology().seconds(), test.secondOfDay()
1398:                        .getDurationField());
1399:                assertEquals(test.getChronology().days(), test.secondOfDay()
1400:                        .getRangeDurationField());
1401:                assertEquals(5, test.secondOfDay().getMaximumTextLength(null));
1402:                assertEquals(5, test.secondOfDay().getMaximumShortTextLength(
1403:                        null));
1404:            }
1405:
1406:            //-----------------------------------------------------------------------
1407:            public void testPropertyGetMillisOfSecond() {
1408:                DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1409:                assertSame(test.getChronology().millisOfSecond(), test
1410:                        .millisOfSecond().getField());
1411:                assertEquals("millisOfSecond", test.millisOfSecond().getName());
1412:                assertEquals("Property[millisOfSecond]", test.millisOfSecond()
1413:                        .toString());
1414:                assertSame(test, test.millisOfSecond().getDateTime());
1415:                assertEquals(53, test.millisOfSecond().get());
1416:                assertEquals("53", test.millisOfSecond().getAsString());
1417:                assertEquals("53", test.millisOfSecond().getAsText());
1418:                assertEquals("53", test.millisOfSecond().getAsText(
1419:                        Locale.FRENCH));
1420:                assertEquals("53", test.millisOfSecond().getAsShortText());
1421:                assertEquals("53", test.millisOfSecond().getAsShortText(
1422:                        Locale.FRENCH));
1423:                assertEquals(test.getChronology().millis(), test
1424:                        .millisOfSecond().getDurationField());
1425:                assertEquals(test.getChronology().seconds(), test
1426:                        .millisOfSecond().getRangeDurationField());
1427:                assertEquals(3, test.millisOfSecond()
1428:                        .getMaximumTextLength(null));
1429:                assertEquals(3, test.millisOfSecond()
1430:                        .getMaximumShortTextLength(null));
1431:            }
1432:
1433:            //-----------------------------------------------------------------------
1434:            public void testPropertyGetMillisOfDay() {
1435:                DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1436:                assertSame(test.getChronology().millisOfDay(), test
1437:                        .millisOfDay().getField());
1438:                assertEquals("millisOfDay", test.millisOfDay().getName());
1439:                assertEquals("Property[millisOfDay]", test.millisOfDay()
1440:                        .toString());
1441:                assertSame(test, test.millisOfDay().getDateTime());
1442:                assertEquals(48223053, test.millisOfDay().get());
1443:                assertEquals("48223053", test.millisOfDay().getAsString());
1444:                assertEquals("48223053", test.millisOfDay().getAsText());
1445:                assertEquals("48223053", test.millisOfDay().getAsText(
1446:                        Locale.FRENCH));
1447:                assertEquals("48223053", test.millisOfDay().getAsShortText());
1448:                assertEquals("48223053", test.millisOfDay().getAsShortText(
1449:                        Locale.FRENCH));
1450:                assertEquals(test.getChronology().millis(), test.millisOfDay()
1451:                        .getDurationField());
1452:                assertEquals(test.getChronology().days(), test.millisOfDay()
1453:                        .getRangeDurationField());
1454:                assertEquals(8, test.millisOfDay().getMaximumTextLength(null));
1455:                assertEquals(8, test.millisOfDay().getMaximumShortTextLength(
1456:                        null));
1457:            }
1458:
1459:            //-----------------------------------------------------------------------
1460:            public void testPropertyToIntervalYearOfEra() {
1461:                DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1462:                Interval testInterval = test.yearOfEra().toInterval();
1463:                assertEquals(new DateTime(2004, 1, 1, 0, 0, 0, 0), testInterval
1464:                        .getStart());
1465:                assertEquals(new DateTime(2005, 1, 1, 0, 0, 0, 0), testInterval
1466:                        .getEnd());
1467:            }
1468:
1469:            public void testPropertyToIntervalYearOfCentury() {
1470:                DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1471:                Interval testInterval = test.yearOfCentury().toInterval();
1472:                assertEquals(new DateTime(2004, 1, 1, 0, 0, 0, 0), testInterval
1473:                        .getStart());
1474:                assertEquals(new DateTime(2005, 1, 1, 0, 0, 0, 0), testInterval
1475:                        .getEnd());
1476:            }
1477:
1478:            public void testPropertyToIntervalYear() {
1479:                DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1480:                Interval testInterval = test.year().toInterval();
1481:                assertEquals(new DateTime(2004, 1, 1, 0, 0, 0, 0), testInterval
1482:                        .getStart());
1483:                assertEquals(new DateTime(2005, 1, 1, 0, 0, 0, 0), testInterval
1484:                        .getEnd());
1485:            }
1486:
1487:            public void testPropertyToIntervalMonthOfYear() {
1488:                DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1489:                Interval testInterval = test.monthOfYear().toInterval();
1490:                assertEquals(new DateTime(2004, 6, 1, 0, 0, 0, 0), testInterval
1491:                        .getStart());
1492:                assertEquals(new DateTime(2004, 7, 1, 0, 0, 0, 0), testInterval
1493:                        .getEnd());
1494:            }
1495:
1496:            public void testPropertyToIntervalDayOfMonth() {
1497:                DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1498:                Interval testInterval = test.dayOfMonth().toInterval();
1499:                assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0), testInterval
1500:                        .getStart());
1501:                assertEquals(new DateTime(2004, 6, 10, 0, 0, 0, 0),
1502:                        testInterval.getEnd());
1503:
1504:                DateTime febTest = new DateTime(2004, 2, 29, 13, 23, 43, 53);
1505:                Interval febTestInterval = febTest.dayOfMonth().toInterval();
1506:                assertEquals(new DateTime(2004, 2, 29, 0, 0, 0, 0),
1507:                        febTestInterval.getStart());
1508:                assertEquals(new DateTime(2004, 3, 1, 0, 0, 0, 0),
1509:                        febTestInterval.getEnd());
1510:            }
1511:
1512:            public void testPropertyToIntervalHourOfDay() {
1513:                DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1514:                Interval testInterval = test.hourOfDay().toInterval();
1515:                assertEquals(new DateTime(2004, 6, 9, 13, 0, 0, 0),
1516:                        testInterval.getStart());
1517:                assertEquals(new DateTime(2004, 6, 9, 14, 0, 0, 0),
1518:                        testInterval.getEnd());
1519:
1520:                DateTime midnightTest = new DateTime(2004, 6, 9, 23, 23, 43, 53);
1521:                Interval midnightTestInterval = midnightTest.hourOfDay()
1522:                        .toInterval();
1523:                assertEquals(new DateTime(2004, 6, 9, 23, 0, 0, 0),
1524:                        midnightTestInterval.getStart());
1525:                assertEquals(new DateTime(2004, 6, 10, 0, 0, 0, 0),
1526:                        midnightTestInterval.getEnd());
1527:            }
1528:
1529:            public void testPropertyToIntervalMinuteOfHour() {
1530:                DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1531:                Interval testInterval = test.minuteOfHour().toInterval();
1532:                assertEquals(new DateTime(2004, 6, 9, 13, 23, 0, 0),
1533:                        testInterval.getStart());
1534:                assertEquals(new DateTime(2004, 6, 9, 13, 24, 0, 0),
1535:                        testInterval.getEnd());
1536:            }
1537:
1538:            public void testPropertyToIntervalSecondOfMinute() {
1539:                DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1540:                Interval testInterval = test.secondOfMinute().toInterval();
1541:                assertEquals(new DateTime(2004, 6, 9, 13, 23, 43, 0),
1542:                        testInterval.getStart());
1543:                assertEquals(new DateTime(2004, 6, 9, 13, 23, 44, 0),
1544:                        testInterval.getEnd());
1545:            }
1546:
1547:            public void testPropertyToIntervalMillisOfSecond() {
1548:                DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1549:                Interval testInterval = test.millisOfSecond().toInterval();
1550:                assertEquals(new DateTime(2004, 6, 9, 13, 23, 43, 53),
1551:                        testInterval.getStart());
1552:                assertEquals(new DateTime(2004, 6, 9, 13, 23, 43, 54),
1553:                        testInterval.getEnd());
1554:            }
1555:
1556:            public void testPropertyEqualsHashCodeLenient() {
1557:                DateTime test1 = new DateTime(1970, 6, 9, 0, 0, 0, 0,
1558:                        LenientChronology.getInstance(COPTIC_PARIS));
1559:                DateTime test2 = new DateTime(1970, 6, 9, 0, 0, 0, 0,
1560:                        LenientChronology.getInstance(COPTIC_PARIS));
1561:                assertEquals(true, test1.dayOfMonth()
1562:                        .equals(test2.dayOfMonth()));
1563:                assertEquals(true, test2.dayOfMonth()
1564:                        .equals(test1.dayOfMonth()));
1565:                assertEquals(true, test1.dayOfMonth()
1566:                        .equals(test1.dayOfMonth()));
1567:                assertEquals(true, test2.dayOfMonth()
1568:                        .equals(test2.dayOfMonth()));
1569:                assertEquals(true, test1.dayOfMonth().hashCode() == test2
1570:                        .dayOfMonth().hashCode());
1571:                assertEquals(true, test1.dayOfMonth().hashCode() == test1
1572:                        .dayOfMonth().hashCode());
1573:                assertEquals(true, test2.dayOfMonth().hashCode() == test2
1574:                        .dayOfMonth().hashCode());
1575:            }
1576:
1577:            public void testPropertyEqualsHashCodeStrict() {
1578:                DateTime test1 = new DateTime(1970, 6, 9, 0, 0, 0, 0,
1579:                        StrictChronology.getInstance(COPTIC_PARIS));
1580:                DateTime test2 = new DateTime(1970, 6, 9, 0, 0, 0, 0,
1581:                        StrictChronology.getInstance(COPTIC_PARIS));
1582:                assertEquals(true, test1.dayOfMonth()
1583:                        .equals(test2.dayOfMonth()));
1584:                assertEquals(true, test2.dayOfMonth()
1585:                        .equals(test1.dayOfMonth()));
1586:                assertEquals(true, test1.dayOfMonth()
1587:                        .equals(test1.dayOfMonth()));
1588:                assertEquals(true, test2.dayOfMonth()
1589:                        .equals(test2.dayOfMonth()));
1590:                assertEquals(true, test1.dayOfMonth().hashCode() == test2
1591:                        .dayOfMonth().hashCode());
1592:                assertEquals(true, test1.dayOfMonth().hashCode() == test1
1593:                        .dayOfMonth().hashCode());
1594:                assertEquals(true, test2.dayOfMonth().hashCode() == test2
1595:                        .dayOfMonth().hashCode());
1596:            }
1597:
1598:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.