View Javadoc

1   /*
2    *  Copyright 2001-2012 Stephen Colebourne
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package org.joda.time;
17  
18  /**
19   * Test testing.
20   */
21  public class TempTest {
22  
23  //    private static final DateTimeZone PARIS = DateTimeZone.forID("Europe/Paris");
24  
25      public static void main(String[] args) {
26          DateTime dateTimeBefore = new DateTime(2012, 10, 28, 2, 59, 0, 0, DateTimeZone.forID("+02:00"));
27          System.out.println(dateTimeBefore);
28          DateTime dateTimeAfter = dateTimeBefore.withSecondOfMinute(0);
29          System.out.println(dateTimeAfter);
30          System.out.println(dateTimeBefore.equals(dateTimeAfter));
31  
32          DateTime dateTimeBefore2 = new DateTime(2012, 10, 28, 2, 59, 0, 0, DateTimeZone.forID("Europe/Berlin"));
33          System.out.println(dateTimeBefore2);
34          DateTime dateTimeAfter2 = dateTimeBefore2.withSecondOfMinute(0);
35          System.out.println(dateTimeAfter2);
36          System.out.println(dateTimeBefore2.equals(dateTimeAfter2));
37  
38          DateTime dateTimeBefore3 = new DateTime(2012, 10, 28, 1, 59, 0, 0, DateTimeZone.forID("Europe/Berlin"));
39          dateTimeBefore3 = dateTimeBefore3.plusMinutes(60); // 2:59 +02:00 with Europe/Berlin
40          System.out.println(dateTimeBefore3);
41          DateTime dateTimeAfter3 = dateTimeBefore2.withSecondOfMinute(0);
42          System.out.println(dateTimeAfter3);
43          // DateTimeZone changed from +02:00 to +01:00
44          System.out.println(dateTimeBefore3.equals(dateTimeAfter3));
45  
46  
47  //        final DateTime start = new LocalDateTime(2012, 11, 4, 1, 30).toDateTime(DateTimeZone.forID("America/New_York"));
48  //        final DateTime end = new LocalDateTime(2012, 11, 4, 2, 0).toDateTime(DateTimeZone.forID("America/New_York"));
49  //        System.out.println(start);
50  //        System.out.println(end);
51  //
52  //        final MutableInterval interval = new MutableInterval(start, end);
53  //        System.out.println(interval);
54  //        System.out.println(new Period(interval));
55  //        System.out.println(Hours.hoursIn(interval));
56  //        System.out.println(Hours.hoursIn(interval).getHours());
57  //        
58  //        // Period is correctly PT1H30, 1 == 1
59  //        Assert.assertEquals(interval.toPeriod().getHours(), Hours.hoursIn(interval).getHours());
60  //
61  //        interval.setStart(interval.getStart().plusHours(1));
62  //        System.out.println("-----");
63  //        System.out.println(interval);
64  //        System.out.println(new Period(interval));
65  //        System.out.println(Hours.hoursIn(interval));
66  //        System.out.println(Hours.hoursIn(interval).getHours());
67  //        // Period is incorrectly PT1H30, 1 == 0
68  //        Assert.assertEquals(Hours.hoursIn(interval).getHours(), interval.toPeriod().getHours());
69          
70  //        DateTimeFormat.forPattern("dd.MM.yyyy").parseDateTime("00.10.2010");
71          
72  //        DateTime dateTime = new DateTime("2010-10-10T04:00:00",
73  //        DateTimeZone.forID("America/Caracas"));
74  //        // time zone is -04:30 -- UTC date time is 2010-10-09T23:30
75  //
76  //        System.out.println(dateTime + " " + dateTime.getChronology());
77  //        MutableDateTime mutableDateTime = dateTime.toMutableDateTime();
78  //        mutableDateTime.setDate(dateTime); // is essentially a no-op
79  //        System.out.println(mutableDateTime + " " + mutableDateTime.getChronology());
80  
81  //        Expected is: 2010-10-10T04:00:00.000-04:30
82  //        Actual result is: 2010-10-09T04:00:00.000-04:30        
83          
84          
85  //      DateTime dt = new DateTime(1, 1, 1, 0, 0, 0, ISOChronology.getInstanceUTC());
86  //      System.out.println(dt + " " + dt.toString("yyyy YYYY GG"));
87  //      dt = dt.minusDays(1);
88  //      System.out.println(dt + " " + dt.toString("yyyy YYYY GG"));
89  //      
90  //      dt = new DateTime(1, 1, 1, 0, 0, 0, GregorianChronology.getInstanceUTC());
91  //      System.out.println(dt + " " + dt.toString("yyyy YYYY GG"));
92  //      dt = dt.minusDays(1);
93  //      System.out.println(dt + " " + dt.toString("yyyy YYYY GG"));
94  //      
95  //      dt = new DateTime(100000, 1, 1, 0, 0, 0, GregorianChronology.getInstanceUTC());
96  //      System.out.println(dt + " " + dt.toString("yyyy YYYY GG"));
97  //      
98  //      dt = new DateTime(-100000, 1, 1, 0, 0, 0, GregorianChronology.getInstanceUTC());
99  //      System.out.println(dt + " " + dt.toString("yyyy YYYY GG"));
100       
101 //      DateTime birth = new DateTime(2012, 03, 31, 02, 28, 0, 0).minus(Years.years(27));
102 //      DateTime now = new DateTime(2012, 03, 31, 02, 28, 33, 0);
103 //      System.out.println(birth);
104 //      System.out.println(now);
105 //      System.out.println(new Period(birth, now));
106       
107 //      // From the first test 
108 //      // Comment out (in) the following call in order to make the test pass (fail). 
109 //      DateTimeZone p1 = DateTimeZone.forID("Europe/Paris");
110 //      System.out.println(p1 + " " + System.identityHashCode(p1));
111 //      DateTimeZone.setDefault(p1); 
112 //      new DateMidnight(2004, 6, 9); 
113 //      // From the first test 
114 //      
115 //      // From the second test 
116 //      DateTimeZone.setProvider(null); 
117 //      // From the second test 
118 //      
119 //      // From the third test 
120 //      DateTimeZone p2 = DateTimeZone.forID("Europe/Paris");
121 //      System.out.println(p2 + " " + System.identityHashCode(p2));
122 //      DateTimeZone.setDefault(p2); 
123 //      
124 //      DateTime test = new DateTime(0); 
125 //      DateTime result = test.withZoneRetainFields(p2); 
126 //      if (test != result) {
127 //        throw new IllegalArgumentException();
128 //      }
129     }
130 
131 }