001    /*
002     *  Copyright 2001-2012 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;
017    
018    /**
019     * Test testing.
020     */
021    public class TempTest {
022    
023    //    private static final DateTimeZone PARIS = DateTimeZone.forID("Europe/Paris");
024    
025        public static void main(String[] args) {
026            DateTime dateTimeBefore = new DateTime(2012, 10, 28, 2, 59, 0, 0, DateTimeZone.forID("+02:00"));
027            System.out.println(dateTimeBefore);
028            DateTime dateTimeAfter = dateTimeBefore.withSecondOfMinute(0);
029            System.out.println(dateTimeAfter);
030            System.out.println(dateTimeBefore.equals(dateTimeAfter));
031    
032            DateTime dateTimeBefore2 = new DateTime(2012, 10, 28, 2, 59, 0, 0, DateTimeZone.forID("Europe/Berlin"));
033            System.out.println(dateTimeBefore2);
034            DateTime dateTimeAfter2 = dateTimeBefore2.withSecondOfMinute(0);
035            System.out.println(dateTimeAfter2);
036            System.out.println(dateTimeBefore2.equals(dateTimeAfter2));
037    
038            DateTime dateTimeBefore3 = new DateTime(2012, 10, 28, 1, 59, 0, 0, DateTimeZone.forID("Europe/Berlin"));
039            dateTimeBefore3 = dateTimeBefore3.plusMinutes(60); // 2:59 +02:00 with Europe/Berlin
040            System.out.println(dateTimeBefore3);
041            DateTime dateTimeAfter3 = dateTimeBefore2.withSecondOfMinute(0);
042            System.out.println(dateTimeAfter3);
043            // DateTimeZone changed from +02:00 to +01:00
044            System.out.println(dateTimeBefore3.equals(dateTimeAfter3));
045    
046    
047    //        final DateTime start = new LocalDateTime(2012, 11, 4, 1, 30).toDateTime(DateTimeZone.forID("America/New_York"));
048    //        final DateTime end = new LocalDateTime(2012, 11, 4, 2, 0).toDateTime(DateTimeZone.forID("America/New_York"));
049    //        System.out.println(start);
050    //        System.out.println(end);
051    //
052    //        final MutableInterval interval = new MutableInterval(start, end);
053    //        System.out.println(interval);
054    //        System.out.println(new Period(interval));
055    //        System.out.println(Hours.hoursIn(interval));
056    //        System.out.println(Hours.hoursIn(interval).getHours());
057    //        
058    //        // Period is correctly PT1H30, 1 == 1
059    //        Assert.assertEquals(interval.toPeriod().getHours(), Hours.hoursIn(interval).getHours());
060    //
061    //        interval.setStart(interval.getStart().plusHours(1));
062    //        System.out.println("-----");
063    //        System.out.println(interval);
064    //        System.out.println(new Period(interval));
065    //        System.out.println(Hours.hoursIn(interval));
066    //        System.out.println(Hours.hoursIn(interval).getHours());
067    //        // Period is incorrectly PT1H30, 1 == 0
068    //        Assert.assertEquals(Hours.hoursIn(interval).getHours(), interval.toPeriod().getHours());
069            
070    //        DateTimeFormat.forPattern("dd.MM.yyyy").parseDateTime("00.10.2010");
071            
072    //        DateTime dateTime = new DateTime("2010-10-10T04:00:00",
073    //        DateTimeZone.forID("America/Caracas"));
074    //        // time zone is -04:30 -- UTC date time is 2010-10-09T23:30
075    //
076    //        System.out.println(dateTime + " " + dateTime.getChronology());
077    //        MutableDateTime mutableDateTime = dateTime.toMutableDateTime();
078    //        mutableDateTime.setDate(dateTime); // is essentially a no-op
079    //        System.out.println(mutableDateTime + " " + mutableDateTime.getChronology());
080    
081    //        Expected is: 2010-10-10T04:00:00.000-04:30
082    //        Actual result is: 2010-10-09T04:00:00.000-04:30        
083            
084            
085    //      DateTime dt = new DateTime(1, 1, 1, 0, 0, 0, ISOChronology.getInstanceUTC());
086    //      System.out.println(dt + " " + dt.toString("yyyy YYYY GG"));
087    //      dt = dt.minusDays(1);
088    //      System.out.println(dt + " " + dt.toString("yyyy YYYY GG"));
089    //      
090    //      dt = new DateTime(1, 1, 1, 0, 0, 0, GregorianChronology.getInstanceUTC());
091    //      System.out.println(dt + " " + dt.toString("yyyy YYYY GG"));
092    //      dt = dt.minusDays(1);
093    //      System.out.println(dt + " " + dt.toString("yyyy YYYY GG"));
094    //      
095    //      dt = new DateTime(100000, 1, 1, 0, 0, 0, GregorianChronology.getInstanceUTC());
096    //      System.out.println(dt + " " + dt.toString("yyyy YYYY GG"));
097    //      
098    //      dt = new DateTime(-100000, 1, 1, 0, 0, 0, GregorianChronology.getInstanceUTC());
099    //      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    }