Source Code Cross Referenced for TestISODateTimeFormat.java in  » Development » Joda-Time » org » joda » time » format » 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.format 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Copyright 2001-2005 Stephen Colebourne
003:         *
004:         *  Licensed under the Apache License, Version 2.0 (the "License");
005:         *  you may not use this file except in compliance with the License.
006:         *  You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         *  Unless required by applicable law or agreed to in writing, software
011:         *  distributed under the License is distributed on an "AS IS" BASIS,
012:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         *  See the License for the specific language governing permissions and
014:         *  limitations under the License.
015:         */
016:        package org.joda.time.format;
017:
018:        import java.util.Locale;
019:        import java.util.TimeZone;
020:
021:        import junit.framework.TestCase;
022:        import junit.framework.TestSuite;
023:
024:        import org.joda.time.DateTime;
025:        import org.joda.time.DateTimeConstants;
026:        import org.joda.time.DateTimeUtils;
027:        import org.joda.time.DateTimeZone;
028:
029:        /**
030:         * This class is a Junit unit test for ISODateTimeFormat.
031:         *
032:         * @author Stephen Colebourne
033:         */
034:        public class TestISODateTimeFormat extends TestCase {
035:
036:            private static final DateTimeZone UTC = DateTimeZone.UTC;
037:            private static final DateTimeZone PARIS = DateTimeZone
038:                    .forID("Europe/Paris");
039:            private static final DateTimeZone LONDON = DateTimeZone
040:                    .forID("Europe/London");
041:            private static final DateTimeZone TOKYO = DateTimeZone
042:                    .forID("Asia/Tokyo");
043:
044:            long y2002days = 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365
045:                    + 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365
046:                    + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365
047:                    + 365 + 365 + 366 + 365;
048:            // 2002-06-09
049:            private long TEST_TIME_NOW = (y2002days + 31L + 28L + 31L + 30L
050:                    + 31L + 9L - 1L)
051:                    * DateTimeConstants.MILLIS_PER_DAY;
052:
053:            private DateTimeZone originalDateTimeZone = null;
054:            private TimeZone originalTimeZone = null;
055:            private Locale originalLocale = null;
056:
057:            public static void main(String[] args) {
058:                junit.textui.TestRunner.run(suite());
059:            }
060:
061:            public static TestSuite suite() {
062:                return new TestSuite(TestISODateTimeFormat.class);
063:            }
064:
065:            public TestISODateTimeFormat(String name) {
066:                super (name);
067:            }
068:
069:            protected void setUp() throws Exception {
070:                DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
071:                originalDateTimeZone = DateTimeZone.getDefault();
072:                originalTimeZone = TimeZone.getDefault();
073:                originalLocale = Locale.getDefault();
074:                DateTimeZone.setDefault(LONDON);
075:                TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
076:                Locale.setDefault(Locale.UK);
077:            }
078:
079:            protected void tearDown() throws Exception {
080:                DateTimeUtils.setCurrentMillisSystem();
081:                DateTimeZone.setDefault(originalDateTimeZone);
082:                TimeZone.setDefault(originalTimeZone);
083:                Locale.setDefault(originalLocale);
084:                originalDateTimeZone = null;
085:                originalTimeZone = null;
086:                originalLocale = null;
087:            }
088:
089:            //-----------------------------------------------------------------------
090:            public void testSubclassableConstructor() {
091:                ISODateTimeFormat f = new ISODateTimeFormat() {
092:                    // test constructor is protected
093:                };
094:                assertNotNull(f);
095:            }
096:
097:            //-----------------------------------------------------------------------
098:            public void testFormat_date() {
099:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
100:                assertEquals("2004-06-09", ISODateTimeFormat.date().print(dt));
101:
102:                dt = dt.withZone(LONDON);
103:                assertEquals("2004-06-09", ISODateTimeFormat.date().print(dt));
104:
105:                dt = dt.withZone(PARIS);
106:                assertEquals("2004-06-09", ISODateTimeFormat.date().print(dt));
107:            }
108:
109:            public void testFormat_time() {
110:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
111:                assertEquals("10:20:30.040Z", ISODateTimeFormat.time()
112:                        .print(dt));
113:
114:                dt = dt.withZone(LONDON);
115:                assertEquals("11:20:30.040+01:00", ISODateTimeFormat.time()
116:                        .print(dt));
117:
118:                dt = dt.withZone(PARIS);
119:                assertEquals("12:20:30.040+02:00", ISODateTimeFormat.time()
120:                        .print(dt));
121:            }
122:
123:            public void testFormat_timeNoMillis() {
124:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
125:                assertEquals("10:20:30Z", ISODateTimeFormat.timeNoMillis()
126:                        .print(dt));
127:
128:                dt = dt.withZone(LONDON);
129:                assertEquals("11:20:30+01:00", ISODateTimeFormat.timeNoMillis()
130:                        .print(dt));
131:
132:                dt = dt.withZone(PARIS);
133:                assertEquals("12:20:30+02:00", ISODateTimeFormat.timeNoMillis()
134:                        .print(dt));
135:            }
136:
137:            public void testFormat_tTime() {
138:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
139:                assertEquals("T10:20:30.040Z", ISODateTimeFormat.tTime().print(
140:                        dt));
141:
142:                dt = dt.withZone(LONDON);
143:                assertEquals("T11:20:30.040+01:00", ISODateTimeFormat.tTime()
144:                        .print(dt));
145:
146:                dt = dt.withZone(PARIS);
147:                assertEquals("T12:20:30.040+02:00", ISODateTimeFormat.tTime()
148:                        .print(dt));
149:            }
150:
151:            public void testFormat_tTimeNoMillis() {
152:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
153:                assertEquals("T10:20:30Z", ISODateTimeFormat.tTimeNoMillis()
154:                        .print(dt));
155:
156:                dt = dt.withZone(LONDON);
157:                assertEquals("T11:20:30+01:00", ISODateTimeFormat
158:                        .tTimeNoMillis().print(dt));
159:
160:                dt = dt.withZone(PARIS);
161:                assertEquals("T12:20:30+02:00", ISODateTimeFormat
162:                        .tTimeNoMillis().print(dt));
163:            }
164:
165:            public void testFormat_dateTime() {
166:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
167:                assertEquals("2004-06-09T10:20:30.040Z", ISODateTimeFormat
168:                        .dateTime().print(dt));
169:
170:                dt = dt.withZone(LONDON);
171:                assertEquals("2004-06-09T11:20:30.040+01:00", ISODateTimeFormat
172:                        .dateTime().print(dt));
173:
174:                dt = dt.withZone(PARIS);
175:                assertEquals("2004-06-09T12:20:30.040+02:00", ISODateTimeFormat
176:                        .dateTime().print(dt));
177:
178:                //        dt = dt.withZone(LONDON);
179:                //        assertEquals("2004-06-09T11:20:30.040+01:00", ISODateTimeFormat.getInstance(PARIS).dateTime().print(dt));
180:                //        
181:                //        dt = dt.withZone(LONDON);
182:                //        assertEquals("2004-06-09T12:20:30.040+02:00", ISODateTimeFormat.dateTime().print(dt.getMillis(), PARIS));
183:                //        
184:                //        dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, CopticChronology.getInstance());
185:                //        assertEquals("2288-02-19T10:20:30.040Z", ISODateTimeFormat.dateTime().print(dt));
186:                //        
187:                //        dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, CopticChronology.getInstance());
188:                //        assertEquals("2004-06-09T10:20:30.040Z", ISODateTimeFormat.getInstance(CopticChronology.getInstance()).dateTime().print(dt));
189:            }
190:
191:            public void testFormat_dateTimeNoMillis() {
192:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
193:                assertEquals("2004-06-09T10:20:30Z", ISODateTimeFormat
194:                        .dateTimeNoMillis().print(dt));
195:
196:                dt = dt.withZone(LONDON);
197:                assertEquals("2004-06-09T11:20:30+01:00", ISODateTimeFormat
198:                        .dateTimeNoMillis().print(dt));
199:
200:                dt = dt.withZone(PARIS);
201:                assertEquals("2004-06-09T12:20:30+02:00", ISODateTimeFormat
202:                        .dateTimeNoMillis().print(dt));
203:            }
204:
205:            public void testFormat_ordinalDate() {
206:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
207:                assertEquals("2004-161", ISODateTimeFormat.ordinalDate().print(
208:                        dt));
209:
210:                dt = dt.withZone(LONDON);
211:                assertEquals("2004-161", ISODateTimeFormat.ordinalDate().print(
212:                        dt));
213:
214:                dt = dt.withZone(PARIS);
215:                assertEquals("2004-161", ISODateTimeFormat.ordinalDate().print(
216:                        dt));
217:            }
218:
219:            public void testFormat_ordinalDateTime() {
220:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
221:                assertEquals("2004-161T10:20:30.040Z", ISODateTimeFormat
222:                        .ordinalDateTime().print(dt));
223:
224:                dt = dt.withZone(LONDON);
225:                assertEquals("2004-161T11:20:30.040+01:00", ISODateTimeFormat
226:                        .ordinalDateTime().print(dt));
227:
228:                dt = dt.withZone(PARIS);
229:                assertEquals("2004-161T12:20:30.040+02:00", ISODateTimeFormat
230:                        .ordinalDateTime().print(dt));
231:            }
232:
233:            public void testFormat_ordinalDateTimeNoMillis() {
234:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
235:                assertEquals("2004-161T10:20:30Z", ISODateTimeFormat
236:                        .ordinalDateTimeNoMillis().print(dt));
237:
238:                dt = dt.withZone(LONDON);
239:                assertEquals("2004-161T11:20:30+01:00", ISODateTimeFormat
240:                        .ordinalDateTimeNoMillis().print(dt));
241:
242:                dt = dt.withZone(PARIS);
243:                assertEquals("2004-161T12:20:30+02:00", ISODateTimeFormat
244:                        .ordinalDateTimeNoMillis().print(dt));
245:            }
246:
247:            public void testFormat_weekDate() {
248:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
249:                assertEquals("2004-W24-3", ISODateTimeFormat.weekDate().print(
250:                        dt));
251:
252:                dt = dt.withZone(LONDON);
253:                assertEquals("2004-W24-3", ISODateTimeFormat.weekDate().print(
254:                        dt));
255:
256:                dt = dt.withZone(PARIS);
257:                assertEquals("2004-W24-3", ISODateTimeFormat.weekDate().print(
258:                        dt));
259:            }
260:
261:            public void testFormat_weekDateTime() {
262:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
263:                assertEquals("2004-W24-3T10:20:30.040Z", ISODateTimeFormat
264:                        .weekDateTime().print(dt));
265:
266:                dt = dt.withZone(LONDON);
267:                assertEquals("2004-W24-3T11:20:30.040+01:00", ISODateTimeFormat
268:                        .weekDateTime().print(dt));
269:
270:                dt = dt.withZone(PARIS);
271:                assertEquals("2004-W24-3T12:20:30.040+02:00", ISODateTimeFormat
272:                        .weekDateTime().print(dt));
273:            }
274:
275:            public void testFormat_weekDateTimeNoMillis() {
276:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
277:                assertEquals("2004-W24-3T10:20:30Z", ISODateTimeFormat
278:                        .weekDateTimeNoMillis().print(dt));
279:
280:                dt = dt.withZone(LONDON);
281:                assertEquals("2004-W24-3T11:20:30+01:00", ISODateTimeFormat
282:                        .weekDateTimeNoMillis().print(dt));
283:
284:                dt = dt.withZone(PARIS);
285:                assertEquals("2004-W24-3T12:20:30+02:00", ISODateTimeFormat
286:                        .weekDateTimeNoMillis().print(dt));
287:            }
288:
289:            //-----------------------------------------------------------------------
290:            public void testFormat_basicDate() {
291:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
292:                assertEquals("20040609", ISODateTimeFormat.basicDate()
293:                        .print(dt));
294:
295:                dt = dt.withZone(LONDON);
296:                assertEquals("20040609", ISODateTimeFormat.basicDate()
297:                        .print(dt));
298:
299:                dt = dt.withZone(PARIS);
300:                assertEquals("20040609", ISODateTimeFormat.basicDate()
301:                        .print(dt));
302:            }
303:
304:            public void testFormat_basicTime() {
305:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
306:                assertEquals("102030.040Z", ISODateTimeFormat.basicTime()
307:                        .print(dt));
308:
309:                dt = dt.withZone(LONDON);
310:                assertEquals("112030.040+0100", ISODateTimeFormat.basicTime()
311:                        .print(dt));
312:
313:                dt = dt.withZone(PARIS);
314:                assertEquals("122030.040+0200", ISODateTimeFormat.basicTime()
315:                        .print(dt));
316:            }
317:
318:            public void testFormat_basicTimeNoMillis() {
319:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
320:                assertEquals("102030Z", ISODateTimeFormat.basicTimeNoMillis()
321:                        .print(dt));
322:
323:                dt = dt.withZone(LONDON);
324:                assertEquals("112030+0100", ISODateTimeFormat
325:                        .basicTimeNoMillis().print(dt));
326:
327:                dt = dt.withZone(PARIS);
328:                assertEquals("122030+0200", ISODateTimeFormat
329:                        .basicTimeNoMillis().print(dt));
330:            }
331:
332:            public void testFormat_basicTTime() {
333:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
334:                assertEquals("T102030.040Z", ISODateTimeFormat.basicTTime()
335:                        .print(dt));
336:
337:                dt = dt.withZone(LONDON);
338:                assertEquals("T112030.040+0100", ISODateTimeFormat.basicTTime()
339:                        .print(dt));
340:
341:                dt = dt.withZone(PARIS);
342:                assertEquals("T122030.040+0200", ISODateTimeFormat.basicTTime()
343:                        .print(dt));
344:            }
345:
346:            public void testFormat_basicTTimeNoMillis() {
347:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
348:                assertEquals("T102030Z", ISODateTimeFormat.basicTTimeNoMillis()
349:                        .print(dt));
350:
351:                dt = dt.withZone(LONDON);
352:                assertEquals("T112030+0100", ISODateTimeFormat
353:                        .basicTTimeNoMillis().print(dt));
354:
355:                dt = dt.withZone(PARIS);
356:                assertEquals("T122030+0200", ISODateTimeFormat
357:                        .basicTTimeNoMillis().print(dt));
358:            }
359:
360:            public void testFormat_basicDateTime() {
361:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
362:                assertEquals("20040609T102030.040Z", ISODateTimeFormat
363:                        .basicDateTime().print(dt));
364:
365:                dt = dt.withZone(LONDON);
366:                assertEquals("20040609T112030.040+0100", ISODateTimeFormat
367:                        .basicDateTime().print(dt));
368:
369:                dt = dt.withZone(PARIS);
370:                assertEquals("20040609T122030.040+0200", ISODateTimeFormat
371:                        .basicDateTime().print(dt));
372:            }
373:
374:            public void testFormat_basicDateTimeNoMillis() {
375:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
376:                assertEquals("20040609T102030Z", ISODateTimeFormat
377:                        .basicDateTimeNoMillis().print(dt));
378:
379:                dt = dt.withZone(LONDON);
380:                assertEquals("20040609T112030+0100", ISODateTimeFormat
381:                        .basicDateTimeNoMillis().print(dt));
382:
383:                dt = dt.withZone(PARIS);
384:                assertEquals("20040609T122030+0200", ISODateTimeFormat
385:                        .basicDateTimeNoMillis().print(dt));
386:            }
387:
388:            public void testFormat_basicOrdinalDate() {
389:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
390:                assertEquals("2004161", ISODateTimeFormat.basicOrdinalDate()
391:                        .print(dt));
392:
393:                dt = dt.withZone(LONDON);
394:                assertEquals("2004161", ISODateTimeFormat.basicOrdinalDate()
395:                        .print(dt));
396:
397:                dt = dt.withZone(PARIS);
398:                assertEquals("2004161", ISODateTimeFormat.basicOrdinalDate()
399:                        .print(dt));
400:            }
401:
402:            public void testFormat_basicOrdinalDateTime() {
403:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
404:                assertEquals("2004161T102030.040Z", ISODateTimeFormat
405:                        .basicOrdinalDateTime().print(dt));
406:
407:                dt = dt.withZone(LONDON);
408:                assertEquals("2004161T112030.040+0100", ISODateTimeFormat
409:                        .basicOrdinalDateTime().print(dt));
410:
411:                dt = dt.withZone(PARIS);
412:                assertEquals("2004161T122030.040+0200", ISODateTimeFormat
413:                        .basicOrdinalDateTime().print(dt));
414:            }
415:
416:            public void testFormat_basicOrdinalDateTimeNoMillis() {
417:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
418:                assertEquals("2004161T102030Z", ISODateTimeFormat
419:                        .basicOrdinalDateTimeNoMillis().print(dt));
420:
421:                dt = dt.withZone(LONDON);
422:                assertEquals("2004161T112030+0100", ISODateTimeFormat
423:                        .basicOrdinalDateTimeNoMillis().print(dt));
424:
425:                dt = dt.withZone(PARIS);
426:                assertEquals("2004161T122030+0200", ISODateTimeFormat
427:                        .basicOrdinalDateTimeNoMillis().print(dt));
428:            }
429:
430:            public void testFormat_basicWeekDate() {
431:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
432:                assertEquals("2004W243", ISODateTimeFormat.basicWeekDate()
433:                        .print(dt));
434:
435:                dt = dt.withZone(LONDON);
436:                assertEquals("2004W243", ISODateTimeFormat.basicWeekDate()
437:                        .print(dt));
438:
439:                dt = dt.withZone(PARIS);
440:                assertEquals("2004W243", ISODateTimeFormat.basicWeekDate()
441:                        .print(dt));
442:            }
443:
444:            public void testFormat_basicWeekDateTime() {
445:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
446:                assertEquals("2004W243T102030.040Z", ISODateTimeFormat
447:                        .basicWeekDateTime().print(dt));
448:
449:                dt = dt.withZone(LONDON);
450:                assertEquals("2004W243T112030.040+0100", ISODateTimeFormat
451:                        .basicWeekDateTime().print(dt));
452:
453:                dt = dt.withZone(PARIS);
454:                assertEquals("2004W243T122030.040+0200", ISODateTimeFormat
455:                        .basicWeekDateTime().print(dt));
456:            }
457:
458:            public void testFormat_basicWeekDateTimeNoMillis() {
459:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
460:                assertEquals("2004W243T102030Z", ISODateTimeFormat
461:                        .basicWeekDateTimeNoMillis().print(dt));
462:
463:                dt = dt.withZone(LONDON);
464:                assertEquals("2004W243T112030+0100", ISODateTimeFormat
465:                        .basicWeekDateTimeNoMillis().print(dt));
466:
467:                dt = dt.withZone(PARIS);
468:                assertEquals("2004W243T122030+0200", ISODateTimeFormat
469:                        .basicWeekDateTimeNoMillis().print(dt));
470:            }
471:
472:            //-----------------------------------------------------------------------
473:            public void testFormat_year() {
474:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
475:                assertEquals("2004", ISODateTimeFormat.year().print(dt));
476:
477:                dt = dt.withZone(LONDON);
478:                assertEquals("2004", ISODateTimeFormat.year().print(dt));
479:
480:                dt = dt.withZone(PARIS);
481:                assertEquals("2004", ISODateTimeFormat.year().print(dt));
482:            }
483:
484:            public void testFormat_yearMonth() {
485:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
486:                assertEquals("2004-06", ISODateTimeFormat.yearMonth().print(dt));
487:
488:                dt = dt.withZone(LONDON);
489:                assertEquals("2004-06", ISODateTimeFormat.yearMonth().print(dt));
490:
491:                dt = dt.withZone(PARIS);
492:                assertEquals("2004-06", ISODateTimeFormat.yearMonth().print(dt));
493:            }
494:
495:            public void testFormat_yearMonthDay() {
496:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
497:                assertEquals("2004-06-09", ISODateTimeFormat.yearMonthDay()
498:                        .print(dt));
499:
500:                dt = dt.withZone(LONDON);
501:                assertEquals("2004-06-09", ISODateTimeFormat.yearMonthDay()
502:                        .print(dt));
503:
504:                dt = dt.withZone(PARIS);
505:                assertEquals("2004-06-09", ISODateTimeFormat.yearMonthDay()
506:                        .print(dt));
507:            }
508:
509:            public void testFormat_weekyear() {
510:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
511:                assertEquals("2004", ISODateTimeFormat.weekyear().print(dt));
512:
513:                dt = dt.withZone(LONDON);
514:                assertEquals("2004", ISODateTimeFormat.weekyear().print(dt));
515:
516:                dt = dt.withZone(PARIS);
517:                assertEquals("2004", ISODateTimeFormat.weekyear().print(dt));
518:            }
519:
520:            public void testFormat_weekyearWeek() {
521:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
522:                assertEquals("2004-W24", ISODateTimeFormat.weekyearWeek()
523:                        .print(dt));
524:
525:                dt = dt.withZone(LONDON);
526:                assertEquals("2004-W24", ISODateTimeFormat.weekyearWeek()
527:                        .print(dt));
528:
529:                dt = dt.withZone(PARIS);
530:                assertEquals("2004-W24", ISODateTimeFormat.weekyearWeek()
531:                        .print(dt));
532:            }
533:
534:            public void testFormat_weekyearWeekDay() {
535:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
536:                assertEquals("2004-W24-3", ISODateTimeFormat.weekyearWeekDay()
537:                        .print(dt));
538:
539:                dt = dt.withZone(LONDON);
540:                assertEquals("2004-W24-3", ISODateTimeFormat.weekyearWeekDay()
541:                        .print(dt));
542:
543:                dt = dt.withZone(PARIS);
544:                assertEquals("2004-W24-3", ISODateTimeFormat.weekyearWeekDay()
545:                        .print(dt));
546:            }
547:
548:            //-----------------------------------------------------------------------
549:            public void testFormat_hour() {
550:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
551:                assertEquals("10", ISODateTimeFormat.hour().print(dt));
552:
553:                dt = dt.withZone(LONDON);
554:                assertEquals("11", ISODateTimeFormat.hour().print(dt));
555:
556:                dt = dt.withZone(PARIS);
557:                assertEquals("12", ISODateTimeFormat.hour().print(dt));
558:            }
559:
560:            public void testFormat_hourMinute() {
561:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
562:                assertEquals("10:20", ISODateTimeFormat.hourMinute().print(dt));
563:
564:                dt = dt.withZone(LONDON);
565:                assertEquals("11:20", ISODateTimeFormat.hourMinute().print(dt));
566:
567:                dt = dt.withZone(PARIS);
568:                assertEquals("12:20", ISODateTimeFormat.hourMinute().print(dt));
569:            }
570:
571:            public void testFormat_hourMinuteSecond() {
572:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
573:                assertEquals("10:20:30", ISODateTimeFormat.hourMinuteSecond()
574:                        .print(dt));
575:
576:                dt = dt.withZone(LONDON);
577:                assertEquals("11:20:30", ISODateTimeFormat.hourMinuteSecond()
578:                        .print(dt));
579:
580:                dt = dt.withZone(PARIS);
581:                assertEquals("12:20:30", ISODateTimeFormat.hourMinuteSecond()
582:                        .print(dt));
583:            }
584:
585:            public void testFormat_hourMinuteSecondMillis() {
586:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
587:                assertEquals("10:20:30.040", ISODateTimeFormat
588:                        .hourMinuteSecondMillis().print(dt));
589:
590:                dt = dt.withZone(LONDON);
591:                assertEquals("11:20:30.040", ISODateTimeFormat
592:                        .hourMinuteSecondMillis().print(dt));
593:
594:                dt = dt.withZone(PARIS);
595:                assertEquals("12:20:30.040", ISODateTimeFormat
596:                        .hourMinuteSecondMillis().print(dt));
597:            }
598:
599:            public void testFormat_hourMinuteSecondFraction() {
600:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
601:                assertEquals("10:20:30.040", ISODateTimeFormat
602:                        .hourMinuteSecondFraction().print(dt));
603:
604:                dt = dt.withZone(LONDON);
605:                assertEquals("11:20:30.040", ISODateTimeFormat
606:                        .hourMinuteSecondFraction().print(dt));
607:
608:                dt = dt.withZone(PARIS);
609:                assertEquals("12:20:30.040", ISODateTimeFormat
610:                        .hourMinuteSecondFraction().print(dt));
611:            }
612:
613:            //-----------------------------------------------------------------------
614:            public void testFormat_dateHour() {
615:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
616:                assertEquals("2004-06-09T10", ISODateTimeFormat.dateHour()
617:                        .print(dt));
618:
619:                dt = dt.withZone(LONDON);
620:                assertEquals("2004-06-09T11", ISODateTimeFormat.dateHour()
621:                        .print(dt));
622:
623:                dt = dt.withZone(PARIS);
624:                assertEquals("2004-06-09T12", ISODateTimeFormat.dateHour()
625:                        .print(dt));
626:            }
627:
628:            public void testFormat_dateHourMinute() {
629:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
630:                assertEquals("2004-06-09T10:20", ISODateTimeFormat
631:                        .dateHourMinute().print(dt));
632:
633:                dt = dt.withZone(LONDON);
634:                assertEquals("2004-06-09T11:20", ISODateTimeFormat
635:                        .dateHourMinute().print(dt));
636:
637:                dt = dt.withZone(PARIS);
638:                assertEquals("2004-06-09T12:20", ISODateTimeFormat
639:                        .dateHourMinute().print(dt));
640:            }
641:
642:            public void testFormat_dateHourMinuteSecond() {
643:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
644:                assertEquals("2004-06-09T10:20:30", ISODateTimeFormat
645:                        .dateHourMinuteSecond().print(dt));
646:
647:                dt = dt.withZone(LONDON);
648:                assertEquals("2004-06-09T11:20:30", ISODateTimeFormat
649:                        .dateHourMinuteSecond().print(dt));
650:
651:                dt = dt.withZone(PARIS);
652:                assertEquals("2004-06-09T12:20:30", ISODateTimeFormat
653:                        .dateHourMinuteSecond().print(dt));
654:            }
655:
656:            public void testFormat_dateHourMinuteSecondMillis() {
657:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
658:                assertEquals("2004-06-09T10:20:30.040", ISODateTimeFormat
659:                        .dateHourMinuteSecondMillis().print(dt));
660:
661:                dt = dt.withZone(LONDON);
662:                assertEquals("2004-06-09T11:20:30.040", ISODateTimeFormat
663:                        .dateHourMinuteSecondMillis().print(dt));
664:
665:                dt = dt.withZone(PARIS);
666:                assertEquals("2004-06-09T12:20:30.040", ISODateTimeFormat
667:                        .dateHourMinuteSecondMillis().print(dt));
668:            }
669:
670:            public void testFormat_dateHourMinuteSecondFraction() {
671:                DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 40, UTC);
672:                assertEquals("2004-06-09T10:20:30.040", ISODateTimeFormat
673:                        .dateHourMinuteSecondFraction().print(dt));
674:
675:                dt = dt.withZone(LONDON);
676:                assertEquals("2004-06-09T11:20:30.040", ISODateTimeFormat
677:                        .dateHourMinuteSecondFraction().print(dt));
678:
679:                dt = dt.withZone(PARIS);
680:                assertEquals("2004-06-09T12:20:30.040", ISODateTimeFormat
681:                        .dateHourMinuteSecondFraction().print(dt));
682:            }
683:
684:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.