~ubuntu-branches/ubuntu/precise/libjoda-time-java/precise

« back to all changes in this revision

Viewing changes to src/test/org/joda/time/TestDateTimeZoneCutover.java

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2011-02-09 23:05:14 UTC
  • mfrom: (5.2.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110209230514-22otglg8nm2y2y2n
Tags: 1.6.2-2
* Upload to unstable.
* Add (temporary) Build-Depends: ant.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  Copyright 2001-2007 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
 
import junit.framework.TestCase;
19
 
import junit.framework.TestSuite;
20
 
 
21
 
/**
22
 
 * This class is a JUnit test for DateTimeZone.
23
 
 *
24
 
 * @author Stephen Colebourne
25
 
 */
26
 
public class TestDateTimeZoneCutover extends TestCase {
27
 
 
28
 
    public static void main(String[] args) {
29
 
        junit.textui.TestRunner.run(suite());
30
 
    }
31
 
 
32
 
    public static TestSuite suite() {
33
 
        return new TestSuite(TestDateTimeZoneCutover.class);
34
 
    }
35
 
 
36
 
    public TestDateTimeZoneCutover(String name) {
37
 
        super(name);
38
 
    }
39
 
 
40
 
    protected void setUp() throws Exception {
41
 
    }
42
 
 
43
 
    protected void tearDown() throws Exception {
44
 
    }
45
 
 
46
 
    //-----------------------------------------------------------------------
47
 
    //------------------------ Bug [1710316] --------------------------------
48
 
    //-----------------------------------------------------------------------
49
 
    // The behaviour of getOffsetFromLocal is defined in its javadoc
50
 
    // However, this definition doesn't work for all DateTimeField operations
51
 
    
52
 
    /** Mock zone simulating Asia/Gaza cutover at midnight 2007-04-01 */
53
 
    private static long CUTOVER_GAZA = 1175378400000L;
54
 
    private static int OFFSET_GAZA = 7200000;  // +02:00
55
 
    private static final DateTimeZone MOCK_GAZA = new MockZone(CUTOVER_GAZA, OFFSET_GAZA);
56
 
 
57
 
    //-----------------------------------------------------------------------
58
 
    public void test_MockGazaIsCorrect() {
59
 
        DateTime pre = new DateTime(CUTOVER_GAZA - 1L, MOCK_GAZA);
60
 
        assertEquals("2007-03-31T23:59:59.999+02:00", pre.toString());
61
 
        DateTime at = new DateTime(CUTOVER_GAZA, MOCK_GAZA);
62
 
        assertEquals("2007-04-01T01:00:00.000+03:00", at.toString());
63
 
        DateTime post = new DateTime(CUTOVER_GAZA + 1L, MOCK_GAZA);
64
 
        assertEquals("2007-04-01T01:00:00.001+03:00", post.toString());
65
 
    }
66
 
 
67
 
    public void test_getOffsetFromLocal_Gaza() {
68
 
        doTest_getOffsetFromLocal_Gaza(-1, 23, 0, "2007-03-31T23:00:00.000+02:00");
69
 
        doTest_getOffsetFromLocal_Gaza(-1, 23, 30, "2007-03-31T23:30:00.000+02:00");
70
 
        doTest_getOffsetFromLocal_Gaza(0, 0, 0, "2007-04-01T01:00:00.000+03:00");
71
 
        doTest_getOffsetFromLocal_Gaza(0, 0, 30, "2007-04-01T01:30:00.000+03:00");
72
 
        doTest_getOffsetFromLocal_Gaza(0, 1, 0, "2007-04-01T01:00:00.000+03:00");
73
 
        doTest_getOffsetFromLocal_Gaza(0, 1, 30, "2007-04-01T01:30:00.000+03:00");
74
 
        doTest_getOffsetFromLocal_Gaza(0, 2, 0, "2007-04-01T02:00:00.000+03:00");
75
 
        doTest_getOffsetFromLocal_Gaza(0, 3, 0, "2007-04-01T03:00:00.000+03:00");
76
 
        doTest_getOffsetFromLocal_Gaza(0, 4, 0, "2007-04-01T04:00:00.000+03:00");
77
 
        doTest_getOffsetFromLocal_Gaza(0, 5, 0, "2007-04-01T05:00:00.000+03:00");
78
 
        doTest_getOffsetFromLocal_Gaza(0, 6, 0, "2007-04-01T06:00:00.000+03:00");
79
 
    }
80
 
 
81
 
    private void doTest_getOffsetFromLocal_Gaza(int days, int hour, int min, String expected) {
82
 
        DateTime dt = new DateTime(2007, 4, 1, hour, min, 0, 0, DateTimeZone.UTC).plusDays(days);
83
 
        int offset = MOCK_GAZA.getOffsetFromLocal(dt.getMillis());
84
 
        DateTime res = new DateTime(dt.getMillis() - offset, MOCK_GAZA);
85
 
        assertEquals(res.toString(), expected, res.toString());
86
 
    }
87
 
 
88
 
    public void test_DateTime_roundFloor_Gaza() {
89
 
        DateTime dt = new DateTime(2007, 4, 1, 8, 0, 0, 0, MOCK_GAZA);
90
 
        assertEquals("2007-04-01T08:00:00.000+03:00", dt.toString());
91
 
        DateTime rounded = dt.dayOfMonth().roundFloorCopy();
92
 
        assertEquals("2007-04-01T01:00:00.000+03:00", rounded.toString());
93
 
    }
94
 
 
95
 
    public void test_DateTime_roundCeiling_Gaza() {
96
 
        DateTime dt = new DateTime(2007, 3, 31, 20, 0, 0, 0, MOCK_GAZA);
97
 
        assertEquals("2007-03-31T20:00:00.000+02:00", dt.toString());
98
 
        DateTime rounded = dt.dayOfMonth().roundCeilingCopy();
99
 
        assertEquals("2007-04-01T01:00:00.000+03:00", rounded.toString());
100
 
    }
101
 
 
102
 
    public void test_DateTime_setHourZero_Gaza() {
103
 
        DateTime dt = new DateTime(2007, 4, 1, 8, 0, 0, 0, MOCK_GAZA);
104
 
        assertEquals("2007-04-01T08:00:00.000+03:00", dt.toString());
105
 
        try {
106
 
            dt.hourOfDay().setCopy(0);
107
 
            fail();
108
 
        } catch (IllegalFieldValueException ex) {
109
 
            // expected
110
 
        }
111
 
    }
112
 
 
113
 
    public void test_DateTime_withHourZero_Gaza() {
114
 
        DateTime dt = new DateTime(2007, 4, 1, 8, 0, 0, 0, MOCK_GAZA);
115
 
        assertEquals("2007-04-01T08:00:00.000+03:00", dt.toString());
116
 
        try {
117
 
            dt.withHourOfDay(0);
118
 
            fail();
119
 
        } catch (IllegalFieldValueException ex) {
120
 
            // expected
121
 
        }
122
 
    }
123
 
 
124
 
    public void test_DateTime_withDay_Gaza() {
125
 
        DateTime dt = new DateTime(2007, 4, 2, 0, 0, 0, 0, MOCK_GAZA);
126
 
        assertEquals("2007-04-02T00:00:00.000+03:00", dt.toString());
127
 
        DateTime res = dt.withDayOfMonth(1);
128
 
        assertEquals("2007-04-01T01:00:00.000+03:00", res.toString());
129
 
    }
130
 
 
131
 
    public void test_DateTime_minusHour_Gaza() {
132
 
        DateTime dt = new DateTime(2007, 4, 1, 8, 0, 0, 0, MOCK_GAZA);
133
 
        assertEquals("2007-04-01T08:00:00.000+03:00", dt.toString());
134
 
        
135
 
        DateTime minus7 = dt.minusHours(7);
136
 
        assertEquals("2007-04-01T01:00:00.000+03:00", minus7.toString());
137
 
        DateTime minus8 = dt.minusHours(8);
138
 
        assertEquals("2007-03-31T23:00:00.000+02:00", minus8.toString());
139
 
        DateTime minus9 = dt.minusHours(9);
140
 
        assertEquals("2007-03-31T22:00:00.000+02:00", minus9.toString());
141
 
    }
142
 
 
143
 
    public void test_DateTime_plusHour_Gaza() {
144
 
        DateTime dt = new DateTime(2007, 3, 31, 16, 0, 0, 0, MOCK_GAZA);
145
 
        assertEquals("2007-03-31T16:00:00.000+02:00", dt.toString());
146
 
        
147
 
        DateTime plus7 = dt.plusHours(7);
148
 
        assertEquals("2007-03-31T23:00:00.000+02:00", plus7.toString());
149
 
        DateTime plus8 = dt.plusHours(8);
150
 
        assertEquals("2007-04-01T01:00:00.000+03:00", plus8.toString());
151
 
        DateTime plus9 = dt.plusHours(9);
152
 
        assertEquals("2007-04-01T02:00:00.000+03:00", plus9.toString());
153
 
    }
154
 
 
155
 
    public void test_DateTime_minusDay_Gaza() {
156
 
        DateTime dt = new DateTime(2007, 4, 2, 0, 0, 0, 0, MOCK_GAZA);
157
 
        assertEquals("2007-04-02T00:00:00.000+03:00", dt.toString());
158
 
        
159
 
        DateTime minus1 = dt.minusDays(1);
160
 
        assertEquals("2007-04-01T01:00:00.000+03:00", minus1.toString());
161
 
        DateTime minus2 = dt.minusDays(2);
162
 
        assertEquals("2007-03-31T00:00:00.000+02:00", minus2.toString());
163
 
    }
164
 
 
165
 
    public void test_DateTime_plusDay_Gaza() {
166
 
        DateTime dt = new DateTime(2007, 3, 31, 0, 0, 0, 0, MOCK_GAZA);
167
 
        assertEquals("2007-03-31T00:00:00.000+02:00", dt.toString());
168
 
        
169
 
        DateTime plus1 = dt.plusDays(1);
170
 
        assertEquals("2007-04-01T01:00:00.000+03:00", plus1.toString());
171
 
        DateTime plus2 = dt.plusDays(2);
172
 
        assertEquals("2007-04-02T00:00:00.000+03:00", plus2.toString());
173
 
    }
174
 
 
175
 
    public void test_DateTime_plusDayMidGap_Gaza() {
176
 
        DateTime dt = new DateTime(2007, 3, 31, 0, 30, 0, 0, MOCK_GAZA);
177
 
        assertEquals("2007-03-31T00:30:00.000+02:00", dt.toString());
178
 
        
179
 
        DateTime plus1 = dt.plusDays(1);
180
 
        assertEquals("2007-04-01T01:30:00.000+03:00", plus1.toString());
181
 
        DateTime plus2 = dt.plusDays(2);
182
 
        assertEquals("2007-04-02T00:30:00.000+03:00", plus2.toString());
183
 
    }
184
 
 
185
 
    public void test_DateTime_addWrapFieldDay_Gaza() {
186
 
        DateTime dt = new DateTime(2007, 4, 30, 0, 0, 0, 0, MOCK_GAZA);
187
 
        assertEquals("2007-04-30T00:00:00.000+03:00", dt.toString());
188
 
        
189
 
        DateTime plus1 = dt.dayOfMonth().addWrapFieldToCopy(1);
190
 
        assertEquals("2007-04-01T01:00:00.000+03:00", plus1.toString());
191
 
        DateTime plus2 = dt.dayOfMonth().addWrapFieldToCopy(2);
192
 
        assertEquals("2007-04-02T00:00:00.000+03:00", plus2.toString());
193
 
    }
194
 
 
195
 
    public void test_DateTime_withZoneRetainFields_Gaza() {
196
 
        DateTime dt = new DateTime(2007, 4, 1, 0, 0, 0, 0, DateTimeZone.UTC);
197
 
        assertEquals("2007-04-01T00:00:00.000Z", dt.toString());
198
 
        
199
 
        DateTime res = dt.withZoneRetainFields(MOCK_GAZA);
200
 
        assertEquals("2007-04-01T01:00:00.000+03:00", res.toString());
201
 
    }
202
 
 
203
 
    public void test_MutableDateTime_withZoneRetainFields_Gaza() {
204
 
        MutableDateTime dt = new MutableDateTime(2007, 4, 1, 0, 0, 0, 0, DateTimeZone.UTC);
205
 
        assertEquals("2007-04-01T00:00:00.000Z", dt.toString());
206
 
        
207
 
        dt.setZoneRetainFields(MOCK_GAZA);
208
 
        assertEquals("2007-04-01T01:00:00.000+03:00", dt.toString());
209
 
    }
210
 
 
211
 
    public void test_LocalDate_new_Gaza() {
212
 
        LocalDate date1 = new LocalDate(CUTOVER_GAZA, MOCK_GAZA);
213
 
        assertEquals("2007-04-01", date1.toString());
214
 
        
215
 
        LocalDate date2 = new LocalDate(CUTOVER_GAZA - 1, MOCK_GAZA);
216
 
        assertEquals("2007-03-31", date2.toString());
217
 
    }
218
 
 
219
 
    public void test_LocalDate_toDateTimeAtMidnight_Gaza() {
220
 
        LocalDate date = new LocalDate(2007, 4, 1);
221
 
        try {
222
 
            date.toDateTimeAtMidnight(MOCK_GAZA);
223
 
            fail();
224
 
        } catch (IllegalArgumentException ex) {
225
 
            assertEquals(true, ex.getMessage().startsWith("Illegal instant due to time zone offset transition"));
226
 
        }
227
 
    }
228
 
 
229
 
    public void test_LocalDate_toDateMidnight_Gaza() {
230
 
        LocalDate date = new LocalDate(2007, 4, 1);
231
 
        try {
232
 
            date.toDateMidnight(MOCK_GAZA);
233
 
            fail();
234
 
        } catch (IllegalArgumentException ex) {
235
 
            assertEquals(true, ex.getMessage().startsWith("Illegal instant due to time zone offset transition"));
236
 
        }
237
 
    }
238
 
 
239
 
    public void test_DateTime_new_Gaza() {
240
 
        try {
241
 
            new DateTime(2007, 4, 1, 0, 0, 0, 0, MOCK_GAZA);
242
 
            fail();
243
 
        } catch (IllegalArgumentException ex) {
244
 
            assertEquals(true, ex.getMessage().indexOf("Illegal instant due to time zone offset transition") >= 0);
245
 
        }
246
 
    }
247
 
 
248
 
    public void test_DateTime_newValid_Gaza() {
249
 
        new DateTime(2007, 3, 31, 19, 0, 0, 0, MOCK_GAZA);
250
 
        new DateTime(2007, 3, 31, 20, 0, 0, 0, MOCK_GAZA);
251
 
        new DateTime(2007, 3, 31, 21, 0, 0, 0, MOCK_GAZA);
252
 
        new DateTime(2007, 3, 31, 22, 0, 0, 0, MOCK_GAZA);
253
 
        new DateTime(2007, 3, 31, 23, 0, 0, 0, MOCK_GAZA);
254
 
        new DateTime(2007, 4, 1, 1, 0, 0, 0, MOCK_GAZA);
255
 
        new DateTime(2007, 4, 1, 2, 0, 0, 0, MOCK_GAZA);
256
 
        new DateTime(2007, 4, 1, 3, 0, 0, 0, MOCK_GAZA);
257
 
    }
258
 
 
259
 
    public void test_DateTime_parse_Gaza() {
260
 
        try {
261
 
            new DateTime("2007-04-01T00:00", MOCK_GAZA);
262
 
            fail();
263
 
        } catch (IllegalArgumentException ex) {
264
 
            assertEquals(true, ex.getMessage().indexOf("Illegal instant due to time zone offset transition") >= 0);
265
 
        }
266
 
    }
267
 
 
268
 
    //-----------------------------------------------------------------------
269
 
    //------------------------ Bug [1710316] --------------------------------
270
 
    //-----------------------------------------------------------------------
271
 
    /** Mock zone simulating America/Grand_Turk cutover at midnight 2007-04-01 */
272
 
    private static long CUTOVER_TURK = 1175403600000L;
273
 
    private static int OFFSET_TURK = -18000000;  // -05:00
274
 
    private static final DateTimeZone MOCK_TURK = new MockZone(CUTOVER_TURK, OFFSET_TURK);
275
 
 
276
 
    //-----------------------------------------------------------------------
277
 
    public void test_MockTurkIsCorrect() {
278
 
        DateTime pre = new DateTime(CUTOVER_TURK - 1L, MOCK_TURK);
279
 
        assertEquals("2007-03-31T23:59:59.999-05:00", pre.toString());
280
 
        DateTime at = new DateTime(CUTOVER_TURK, MOCK_TURK);
281
 
        assertEquals("2007-04-01T01:00:00.000-04:00", at.toString());
282
 
        DateTime post = new DateTime(CUTOVER_TURK + 1L, MOCK_TURK);
283
 
        assertEquals("2007-04-01T01:00:00.001-04:00", post.toString());
284
 
    }
285
 
 
286
 
    public void test_getOffsetFromLocal_Turk() {
287
 
        doTest_getOffsetFromLocal_Turk(-1, 23, 0, "2007-03-31T23:00:00.000-05:00");
288
 
        doTest_getOffsetFromLocal_Turk(-1, 23, 30, "2007-03-31T23:30:00.000-05:00");
289
 
        doTest_getOffsetFromLocal_Turk(0, 0, 0, "2007-04-01T01:00:00.000-04:00");
290
 
        doTest_getOffsetFromLocal_Turk(0, 0, 30, "2007-04-01T01:30:00.000-04:00");
291
 
        doTest_getOffsetFromLocal_Turk(0, 1, 0, "2007-04-01T01:00:00.000-04:00");
292
 
        doTest_getOffsetFromLocal_Turk(0, 1, 30, "2007-04-01T01:30:00.000-04:00");
293
 
        doTest_getOffsetFromLocal_Turk(0, 2, 0, "2007-04-01T02:00:00.000-04:00");
294
 
        doTest_getOffsetFromLocal_Turk(0, 3, 0, "2007-04-01T03:00:00.000-04:00");
295
 
        doTest_getOffsetFromLocal_Turk(0, 4, 0, "2007-04-01T04:00:00.000-04:00");
296
 
        doTest_getOffsetFromLocal_Turk(0, 5, 0, "2007-04-01T05:00:00.000-04:00");
297
 
        doTest_getOffsetFromLocal_Turk(0, 6, 0, "2007-04-01T06:00:00.000-04:00");
298
 
    }
299
 
 
300
 
    private void doTest_getOffsetFromLocal_Turk(int days, int hour, int min, String expected) {
301
 
        DateTime dt = new DateTime(2007, 4, 1, hour, min, 0, 0, DateTimeZone.UTC).plusDays(days);
302
 
        int offset = MOCK_TURK.getOffsetFromLocal(dt.getMillis());
303
 
        DateTime res = new DateTime(dt.getMillis() - offset, MOCK_TURK);
304
 
        assertEquals(res.toString(), expected, res.toString());
305
 
    }
306
 
 
307
 
    public void test_DateTime_roundFloor_Turk() {
308
 
        DateTime dt = new DateTime(2007, 4, 1, 8, 0, 0, 0, MOCK_TURK);
309
 
        assertEquals("2007-04-01T08:00:00.000-04:00", dt.toString());
310
 
        DateTime rounded = dt.dayOfMonth().roundFloorCopy();
311
 
        assertEquals("2007-04-01T01:00:00.000-04:00", rounded.toString());
312
 
    }
313
 
 
314
 
    public void test_DateTime_roundFloorNotDST_Turk() {
315
 
        DateTime dt = new DateTime(2007, 4, 2, 8, 0, 0, 0, MOCK_TURK);
316
 
        assertEquals("2007-04-02T08:00:00.000-04:00", dt.toString());
317
 
        DateTime rounded = dt.dayOfMonth().roundFloorCopy();
318
 
        assertEquals("2007-04-02T00:00:00.000-04:00", rounded.toString());
319
 
    }
320
 
 
321
 
    public void test_DateTime_roundCeiling_Turk() {
322
 
        DateTime dt = new DateTime(2007, 3, 31, 20, 0, 0, 0, MOCK_TURK);
323
 
        assertEquals("2007-03-31T20:00:00.000-05:00", dt.toString());
324
 
        DateTime rounded = dt.dayOfMonth().roundCeilingCopy();
325
 
        assertEquals("2007-04-01T01:00:00.000-04:00", rounded.toString());
326
 
    }
327
 
 
328
 
    public void test_DateTime_setHourZero_Turk() {
329
 
        DateTime dt = new DateTime(2007, 4, 1, 8, 0, 0, 0, MOCK_TURK);
330
 
        assertEquals("2007-04-01T08:00:00.000-04:00", dt.toString());
331
 
        try {
332
 
            dt.hourOfDay().setCopy(0);
333
 
            fail();
334
 
        } catch (IllegalFieldValueException ex) {
335
 
            // expected
336
 
        }
337
 
    }
338
 
 
339
 
    public void test_DateTime_withHourZero_Turk() {
340
 
        DateTime dt = new DateTime(2007, 4, 1, 8, 0, 0, 0, MOCK_TURK);
341
 
        assertEquals("2007-04-01T08:00:00.000-04:00", dt.toString());
342
 
        try {
343
 
            dt.withHourOfDay(0);
344
 
            fail();
345
 
        } catch (IllegalFieldValueException ex) {
346
 
            // expected
347
 
        }
348
 
    }
349
 
 
350
 
    public void test_DateTime_withDay_Turk() {
351
 
        DateTime dt = new DateTime(2007, 4, 2, 0, 0, 0, 0, MOCK_TURK);
352
 
        assertEquals("2007-04-02T00:00:00.000-04:00", dt.toString());
353
 
        DateTime res = dt.withDayOfMonth(1);
354
 
        assertEquals("2007-04-01T01:00:00.000-04:00", res.toString());
355
 
    }
356
 
 
357
 
    public void test_DateTime_minusHour_Turk() {
358
 
        DateTime dt = new DateTime(2007, 4, 1, 8, 0, 0, 0, MOCK_TURK);
359
 
        assertEquals("2007-04-01T08:00:00.000-04:00", dt.toString());
360
 
        
361
 
        DateTime minus7 = dt.minusHours(7);
362
 
        assertEquals("2007-04-01T01:00:00.000-04:00", minus7.toString());
363
 
        DateTime minus8 = dt.minusHours(8);
364
 
        assertEquals("2007-03-31T23:00:00.000-05:00", minus8.toString());
365
 
        DateTime minus9 = dt.minusHours(9);
366
 
        assertEquals("2007-03-31T22:00:00.000-05:00", minus9.toString());
367
 
    }
368
 
 
369
 
    public void test_DateTime_plusHour_Turk() {
370
 
        DateTime dt = new DateTime(2007, 3, 31, 16, 0, 0, 0, MOCK_TURK);
371
 
        assertEquals("2007-03-31T16:00:00.000-05:00", dt.toString());
372
 
        
373
 
        DateTime plus7 = dt.plusHours(7);
374
 
        assertEquals("2007-03-31T23:00:00.000-05:00", plus7.toString());
375
 
        DateTime plus8 = dt.plusHours(8);
376
 
        assertEquals("2007-04-01T01:00:00.000-04:00", plus8.toString());
377
 
        DateTime plus9 = dt.plusHours(9);
378
 
        assertEquals("2007-04-01T02:00:00.000-04:00", plus9.toString());
379
 
    }
380
 
 
381
 
    public void test_DateTime_minusDay_Turk() {
382
 
        DateTime dt = new DateTime(2007, 4, 2, 0, 0, 0, 0, MOCK_TURK);
383
 
        assertEquals("2007-04-02T00:00:00.000-04:00", dt.toString());
384
 
        
385
 
        DateTime minus1 = dt.minusDays(1);
386
 
        assertEquals("2007-04-01T01:00:00.000-04:00", minus1.toString());
387
 
        DateTime minus2 = dt.minusDays(2);
388
 
        assertEquals("2007-03-31T00:00:00.000-05:00", minus2.toString());
389
 
    }
390
 
 
391
 
    public void test_DateTime_plusDay_Turk() {
392
 
        DateTime dt = new DateTime(2007, 3, 31, 0, 0, 0, 0, MOCK_TURK);
393
 
        assertEquals("2007-03-31T00:00:00.000-05:00", dt.toString());
394
 
        
395
 
        DateTime plus1 = dt.plusDays(1);
396
 
        assertEquals("2007-04-01T01:00:00.000-04:00", plus1.toString());
397
 
        DateTime plus2 = dt.plusDays(2);
398
 
        assertEquals("2007-04-02T00:00:00.000-04:00", plus2.toString());
399
 
    }
400
 
 
401
 
    public void test_DateTime_plusDayMidGap_Turk() {
402
 
        DateTime dt = new DateTime(2007, 3, 31, 0, 30, 0, 0, MOCK_TURK);
403
 
        assertEquals("2007-03-31T00:30:00.000-05:00", dt.toString());
404
 
        
405
 
        DateTime plus1 = dt.plusDays(1);
406
 
        assertEquals("2007-04-01T01:30:00.000-04:00", plus1.toString());
407
 
        DateTime plus2 = dt.plusDays(2);
408
 
        assertEquals("2007-04-02T00:30:00.000-04:00", plus2.toString());
409
 
    }
410
 
 
411
 
    public void test_DateTime_addWrapFieldDay_Turk() {
412
 
        DateTime dt = new DateTime(2007, 4, 30, 0, 0, 0, 0, MOCK_TURK);
413
 
        assertEquals("2007-04-30T00:00:00.000-04:00", dt.toString());
414
 
        
415
 
        DateTime plus1 = dt.dayOfMonth().addWrapFieldToCopy(1);
416
 
        assertEquals("2007-04-01T01:00:00.000-04:00", plus1.toString());
417
 
        DateTime plus2 = dt.dayOfMonth().addWrapFieldToCopy(2);
418
 
        assertEquals("2007-04-02T00:00:00.000-04:00", plus2.toString());
419
 
    }
420
 
 
421
 
    public void test_DateTime_withZoneRetainFields_Turk() {
422
 
        DateTime dt = new DateTime(2007, 4, 1, 0, 0, 0, 0, DateTimeZone.UTC);
423
 
        assertEquals("2007-04-01T00:00:00.000Z", dt.toString());
424
 
        
425
 
        DateTime res = dt.withZoneRetainFields(MOCK_TURK);
426
 
        assertEquals("2007-04-01T01:00:00.000-04:00", res.toString());
427
 
    }
428
 
 
429
 
    public void test_MutableDateTime_setZoneRetainFields_Turk() {
430
 
        MutableDateTime dt = new MutableDateTime(2007, 4, 1, 0, 0, 0, 0, DateTimeZone.UTC);
431
 
        assertEquals("2007-04-01T00:00:00.000Z", dt.toString());
432
 
        
433
 
        dt.setZoneRetainFields(MOCK_TURK);
434
 
        assertEquals("2007-04-01T01:00:00.000-04:00", dt.toString());
435
 
    }
436
 
 
437
 
    public void test_LocalDate_new_Turk() {
438
 
        LocalDate date1 = new LocalDate(CUTOVER_TURK, MOCK_TURK);
439
 
        assertEquals("2007-04-01", date1.toString());
440
 
        
441
 
        LocalDate date2 = new LocalDate(CUTOVER_TURK - 1, MOCK_TURK);
442
 
        assertEquals("2007-03-31", date2.toString());
443
 
    }
444
 
 
445
 
    public void test_LocalDate_toDateTimeAtMidnight_Turk() {
446
 
        LocalDate date = new LocalDate(2007, 4, 1);
447
 
        try {
448
 
            date.toDateTimeAtMidnight(MOCK_TURK);
449
 
            fail();
450
 
        } catch (IllegalArgumentException ex) {
451
 
            assertEquals(true, ex.getMessage().startsWith("Illegal instant due to time zone offset transition"));
452
 
        }
453
 
    }
454
 
 
455
 
    public void test_LocalDate_toDateMidnight_Turk() {
456
 
        LocalDate date = new LocalDate(2007, 4, 1);
457
 
        try {
458
 
            date.toDateMidnight(MOCK_TURK);
459
 
            fail();
460
 
        } catch (IllegalArgumentException ex) {
461
 
            assertEquals(true, ex.getMessage().startsWith("Illegal instant due to time zone offset transition"));
462
 
        }
463
 
    }
464
 
 
465
 
    public void test_DateTime_new_Turk() {
466
 
        try {
467
 
            new DateTime(2007, 4, 1, 0, 0, 0, 0, MOCK_TURK);
468
 
            fail();
469
 
        } catch (IllegalArgumentException ex) {
470
 
            assertEquals(true, ex.getMessage().indexOf("Illegal instant due to time zone offset transition") >= 0);
471
 
        }
472
 
    }
473
 
 
474
 
    public void test_DateTime_newValid_Turk() {
475
 
        new DateTime(2007, 3, 31, 23, 0, 0, 0, MOCK_TURK);
476
 
        new DateTime(2007, 4, 1, 1, 0, 0, 0, MOCK_TURK);
477
 
        new DateTime(2007, 4, 1, 2, 0, 0, 0, MOCK_TURK);
478
 
        new DateTime(2007, 4, 1, 3, 0, 0, 0, MOCK_TURK);
479
 
        new DateTime(2007, 4, 1, 4, 0, 0, 0, MOCK_TURK);
480
 
        new DateTime(2007, 4, 1, 5, 0, 0, 0, MOCK_TURK);
481
 
        new DateTime(2007, 4, 1, 6, 0, 0, 0, MOCK_TURK);
482
 
    }
483
 
 
484
 
    public void test_DateTime_parse_Turk() {
485
 
        try {
486
 
            new DateTime("2007-04-01T00:00", MOCK_TURK);
487
 
            fail();
488
 
        } catch (IllegalArgumentException ex) {
489
 
            assertEquals(true, ex.getMessage().indexOf("Illegal instant due to time zone offset transition") >= 0);
490
 
        }
491
 
    }
492
 
 
493
 
    //-----------------------------------------------------------------------
494
 
    //-----------------------------------------------------------------------
495
 
    //-----------------------------------------------------------------------
496
 
    /** America/New_York cutover from 01:59 to 03:00 on 2007-03-11 */
497
 
    private static long CUTOVER_NEW_YORK_SPRING = 1173596400000L;  // 2007-03-11T03:00:00.000-04:00
498
 
    private static final DateTimeZone ZONE_NEW_YORK = DateTimeZone.forID("America/New_York");
499
 
//  DateTime x = new DateTime(2007, 1, 1, 0, 0, 0, 0, ZONE_NEW_YORK);
500
 
//  System.out.println(ZONE_NEW_YORK.nextTransition(x.getMillis()));
501
 
//  DateTime y = new DateTime(ZONE_NEW_YORK.nextTransition(x.getMillis()), ZONE_NEW_YORK);
502
 
//  System.out.println(y);
503
 
 
504
 
    //-----------------------------------------------------------------------
505
 
    public void test_NewYorkIsCorrect_Spring() {
506
 
        DateTime pre = new DateTime(CUTOVER_NEW_YORK_SPRING - 1L, ZONE_NEW_YORK);
507
 
        assertEquals("2007-03-11T01:59:59.999-05:00", pre.toString());
508
 
        DateTime at = new DateTime(CUTOVER_NEW_YORK_SPRING, ZONE_NEW_YORK);
509
 
        assertEquals("2007-03-11T03:00:00.000-04:00", at.toString());
510
 
        DateTime post = new DateTime(CUTOVER_NEW_YORK_SPRING + 1L, ZONE_NEW_YORK);
511
 
        assertEquals("2007-03-11T03:00:00.001-04:00", post.toString());
512
 
    }
513
 
 
514
 
    public void test_getOffsetFromLocal_NewYork_Spring() {
515
 
        doTest_getOffsetFromLocal(3, 11, 1, 0, "2007-03-11T01:00:00.000-05:00", ZONE_NEW_YORK);
516
 
        doTest_getOffsetFromLocal(3, 11, 1,30, "2007-03-11T01:30:00.000-05:00", ZONE_NEW_YORK);
517
 
        
518
 
        doTest_getOffsetFromLocal(3, 11, 2, 0, "2007-03-11T03:00:00.000-04:00", ZONE_NEW_YORK);
519
 
        doTest_getOffsetFromLocal(3, 11, 2,30, "2007-03-11T03:30:00.000-04:00", ZONE_NEW_YORK);
520
 
        
521
 
        doTest_getOffsetFromLocal(3, 11, 3, 0, "2007-03-11T03:00:00.000-04:00", ZONE_NEW_YORK);
522
 
        doTest_getOffsetFromLocal(3, 11, 3,30, "2007-03-11T03:30:00.000-04:00", ZONE_NEW_YORK);
523
 
        doTest_getOffsetFromLocal(3, 11, 4, 0, "2007-03-11T04:00:00.000-04:00", ZONE_NEW_YORK);
524
 
        doTest_getOffsetFromLocal(3, 11, 5, 0, "2007-03-11T05:00:00.000-04:00", ZONE_NEW_YORK);
525
 
        doTest_getOffsetFromLocal(3, 11, 6, 0, "2007-03-11T06:00:00.000-04:00", ZONE_NEW_YORK);
526
 
        doTest_getOffsetFromLocal(3, 11, 7, 0, "2007-03-11T07:00:00.000-04:00", ZONE_NEW_YORK);
527
 
        doTest_getOffsetFromLocal(3, 11, 8, 0, "2007-03-11T08:00:00.000-04:00", ZONE_NEW_YORK);
528
 
    }
529
 
 
530
 
    public void test_DateTime_setHourAcross_NewYork_Spring() {
531
 
        DateTime dt = new DateTime(2007, 3, 11, 0, 0, 0, 0, ZONE_NEW_YORK);
532
 
        assertEquals("2007-03-11T00:00:00.000-05:00", dt.toString());
533
 
        DateTime res = dt.hourOfDay().setCopy(4);
534
 
        assertEquals("2007-03-11T04:00:00.000-04:00", res.toString());
535
 
    }
536
 
 
537
 
    public void test_DateTime_setHourForward_NewYork_Spring() {
538
 
        DateTime dt = new DateTime(2007, 3, 11, 0, 0, 0, 0, ZONE_NEW_YORK);
539
 
        assertEquals("2007-03-11T00:00:00.000-05:00", dt.toString());
540
 
        
541
 
        try {
542
 
            dt.hourOfDay().setCopy(2);
543
 
            fail();
544
 
        } catch (IllegalFieldValueException ex) {
545
 
            // expected
546
 
        }
547
 
    }
548
 
 
549
 
    public void test_DateTime_setHourBack_NewYork_Spring() {
550
 
        DateTime dt = new DateTime(2007, 3, 11, 8, 0, 0, 0, ZONE_NEW_YORK);
551
 
        assertEquals("2007-03-11T08:00:00.000-04:00", dt.toString());
552
 
        
553
 
        try {
554
 
            dt.hourOfDay().setCopy(2);
555
 
            fail();
556
 
        } catch (IllegalFieldValueException ex) {
557
 
            // expected
558
 
        }
559
 
    }
560
 
 
561
 
    //-----------------------------------------------------------------------
562
 
    public void test_DateTime_roundFloor_day_NewYork_Spring_preCutover() {
563
 
        DateTime dt = new DateTime(2007, 3, 11, 1, 30, 0, 0, ZONE_NEW_YORK);
564
 
        assertEquals("2007-03-11T01:30:00.000-05:00", dt.toString());
565
 
        DateTime rounded = dt.dayOfMonth().roundFloorCopy();
566
 
        assertEquals("2007-03-11T00:00:00.000-05:00", rounded.toString());
567
 
    }
568
 
 
569
 
    public void test_DateTime_roundFloor_day_NewYork_Spring_postCutover() {
570
 
        DateTime dt = new DateTime(2007, 3, 11, 3, 30, 0, 0, ZONE_NEW_YORK);
571
 
        assertEquals("2007-03-11T03:30:00.000-04:00", dt.toString());
572
 
        DateTime rounded = dt.dayOfMonth().roundFloorCopy();
573
 
        assertEquals("2007-03-11T00:00:00.000-05:00", rounded.toString());
574
 
    }
575
 
 
576
 
    public void test_DateTime_roundFloor_hour_NewYork_Spring_preCutover() {
577
 
        DateTime dt = new DateTime(2007, 3, 11, 1, 30, 0, 0, ZONE_NEW_YORK);
578
 
        assertEquals("2007-03-11T01:30:00.000-05:00", dt.toString());
579
 
        DateTime rounded = dt.hourOfDay().roundFloorCopy();
580
 
        assertEquals("2007-03-11T01:00:00.000-05:00", rounded.toString());
581
 
    }
582
 
 
583
 
    public void test_DateTime_roundFloor_hour_NewYork_Spring_postCutover() {
584
 
        DateTime dt = new DateTime(2007, 3, 11, 3, 30, 0, 0, ZONE_NEW_YORK);
585
 
        assertEquals("2007-03-11T03:30:00.000-04:00", dt.toString());
586
 
        DateTime rounded = dt.hourOfDay().roundFloorCopy();
587
 
        assertEquals("2007-03-11T03:00:00.000-04:00", rounded.toString());
588
 
    }
589
 
 
590
 
    public void test_DateTime_roundFloor_minute_NewYork_Spring_preCutover() {
591
 
        DateTime dt = new DateTime(2007, 3, 11, 1, 30, 40, 0, ZONE_NEW_YORK);
592
 
        assertEquals("2007-03-11T01:30:40.000-05:00", dt.toString());
593
 
        DateTime rounded = dt.minuteOfHour().roundFloorCopy();
594
 
        assertEquals("2007-03-11T01:30:00.000-05:00", rounded.toString());
595
 
    }
596
 
 
597
 
    public void test_DateTime_roundFloor_minute_NewYork_Spring_postCutover() {
598
 
        DateTime dt = new DateTime(2007, 3, 11, 3, 30, 40, 0, ZONE_NEW_YORK);
599
 
        assertEquals("2007-03-11T03:30:40.000-04:00", dt.toString());
600
 
        DateTime rounded = dt.minuteOfHour().roundFloorCopy();
601
 
        assertEquals("2007-03-11T03:30:00.000-04:00", rounded.toString());
602
 
    }
603
 
 
604
 
    //-----------------------------------------------------------------------
605
 
    public void test_DateTime_roundCeiling_day_NewYork_Spring_preCutover() {
606
 
        DateTime dt = new DateTime(2007, 3, 11, 1, 30, 0, 0, ZONE_NEW_YORK);
607
 
        assertEquals("2007-03-11T01:30:00.000-05:00", dt.toString());
608
 
        DateTime rounded = dt.dayOfMonth().roundCeilingCopy();
609
 
        assertEquals("2007-03-12T00:00:00.000-04:00", rounded.toString());
610
 
    }
611
 
 
612
 
    public void test_DateTime_roundCeiling_day_NewYork_Spring_postCutover() {
613
 
        DateTime dt = new DateTime(2007, 3, 11, 3, 30, 0, 0, ZONE_NEW_YORK);
614
 
        assertEquals("2007-03-11T03:30:00.000-04:00", dt.toString());
615
 
        DateTime rounded = dt.dayOfMonth().roundCeilingCopy();
616
 
        assertEquals("2007-03-12T00:00:00.000-04:00", rounded.toString());
617
 
    }
618
 
 
619
 
    public void test_DateTime_roundCeiling_hour_NewYork_Spring_preCutover() {
620
 
        DateTime dt = new DateTime(2007, 3, 11, 1, 30, 0, 0, ZONE_NEW_YORK);
621
 
        assertEquals("2007-03-11T01:30:00.000-05:00", dt.toString());
622
 
        DateTime rounded = dt.hourOfDay().roundCeilingCopy();
623
 
        assertEquals("2007-03-11T03:00:00.000-04:00", rounded.toString());
624
 
    }
625
 
 
626
 
    public void test_DateTime_roundCeiling_hour_NewYork_Spring_postCutover() {
627
 
        DateTime dt = new DateTime(2007, 3, 11, 3, 30, 0, 0, ZONE_NEW_YORK);
628
 
        assertEquals("2007-03-11T03:30:00.000-04:00", dt.toString());
629
 
        DateTime rounded = dt.hourOfDay().roundCeilingCopy();
630
 
        assertEquals("2007-03-11T04:00:00.000-04:00", rounded.toString());
631
 
    }
632
 
 
633
 
    public void test_DateTime_roundCeiling_minute_NewYork_Spring_preCutover() {
634
 
        DateTime dt = new DateTime(2007, 3, 11, 1, 30, 40, 0, ZONE_NEW_YORK);
635
 
        assertEquals("2007-03-11T01:30:40.000-05:00", dt.toString());
636
 
        DateTime rounded = dt.minuteOfHour().roundCeilingCopy();
637
 
        assertEquals("2007-03-11T01:31:00.000-05:00", rounded.toString());
638
 
    }
639
 
 
640
 
    public void test_DateTime_roundCeiling_minute_NewYork_Spring_postCutover() {
641
 
        DateTime dt = new DateTime(2007, 3, 11, 3, 30, 40, 0, ZONE_NEW_YORK);
642
 
        assertEquals("2007-03-11T03:30:40.000-04:00", dt.toString());
643
 
        DateTime rounded = dt.minuteOfHour().roundCeilingCopy();
644
 
        assertEquals("2007-03-11T03:31:00.000-04:00", rounded.toString());
645
 
    }
646
 
 
647
 
    //-----------------------------------------------------------------------
648
 
    /** America/New_York cutover from 01:59 to 01:00 on 2007-11-04 */
649
 
    private static long CUTOVER_NEW_YORK_AUTUMN = 1194156000000L;  // 2007-11-04T01:00:00.000-05:00
650
 
 
651
 
    //-----------------------------------------------------------------------
652
 
    public void test_NewYorkIsCorrect_Autumn() {
653
 
        DateTime pre = new DateTime(CUTOVER_NEW_YORK_AUTUMN - 1L, ZONE_NEW_YORK);
654
 
        assertEquals("2007-11-04T01:59:59.999-04:00", pre.toString());
655
 
        DateTime at = new DateTime(CUTOVER_NEW_YORK_AUTUMN, ZONE_NEW_YORK);
656
 
        assertEquals("2007-11-04T01:00:00.000-05:00", at.toString());
657
 
        DateTime post = new DateTime(CUTOVER_NEW_YORK_AUTUMN + 1L, ZONE_NEW_YORK);
658
 
        assertEquals("2007-11-04T01:00:00.001-05:00", post.toString());
659
 
    }
660
 
 
661
 
    public void test_getOffsetFromLocal_NewYork_Autumn() {
662
 
        doTest_getOffsetFromLocal(11, 4, 0, 0, "2007-11-04T00:00:00.000-04:00", ZONE_NEW_YORK);
663
 
        doTest_getOffsetFromLocal(11, 4, 0,30, "2007-11-04T00:30:00.000-04:00", ZONE_NEW_YORK);
664
 
        
665
 
        doTest_getOffsetFromLocal(11, 4, 1, 0, "2007-11-04T01:00:00.000-04:00", ZONE_NEW_YORK);
666
 
        doTest_getOffsetFromLocal(11, 4, 1,30, "2007-11-04T01:30:00.000-04:00", ZONE_NEW_YORK);
667
 
        
668
 
        doTest_getOffsetFromLocal(11, 4, 2, 0, "2007-11-04T02:00:00.000-05:00", ZONE_NEW_YORK);
669
 
        doTest_getOffsetFromLocal(11, 4, 2,30, "2007-11-04T02:30:00.000-05:00", ZONE_NEW_YORK);
670
 
        doTest_getOffsetFromLocal(11, 4, 3, 0, "2007-11-04T03:00:00.000-05:00", ZONE_NEW_YORK);
671
 
        doTest_getOffsetFromLocal(11, 4, 3,30, "2007-11-04T03:30:00.000-05:00", ZONE_NEW_YORK);
672
 
        doTest_getOffsetFromLocal(11, 4, 4, 0, "2007-11-04T04:00:00.000-05:00", ZONE_NEW_YORK);
673
 
        doTest_getOffsetFromLocal(11, 4, 5, 0, "2007-11-04T05:00:00.000-05:00", ZONE_NEW_YORK);
674
 
        doTest_getOffsetFromLocal(11, 4, 6, 0, "2007-11-04T06:00:00.000-05:00", ZONE_NEW_YORK);
675
 
        doTest_getOffsetFromLocal(11, 4, 7, 0, "2007-11-04T07:00:00.000-05:00", ZONE_NEW_YORK);
676
 
        doTest_getOffsetFromLocal(11, 4, 8, 0, "2007-11-04T08:00:00.000-05:00", ZONE_NEW_YORK);
677
 
    }
678
 
 
679
 
    public void test_DateTime_plusHour_NewYork_Autumn() {
680
 
        DateTime dt = new DateTime(2007, 11, 3, 18, 0, 0, 0, ZONE_NEW_YORK);
681
 
        assertEquals("2007-11-03T18:00:00.000-04:00", dt.toString());
682
 
        
683
 
        DateTime plus6 = dt.plusHours(6);
684
 
        assertEquals("2007-11-04T00:00:00.000-04:00", plus6.toString());
685
 
        DateTime plus7 = dt.plusHours(7);
686
 
        assertEquals("2007-11-04T01:00:00.000-04:00", plus7.toString());
687
 
        DateTime plus8 = dt.plusHours(8);
688
 
        assertEquals("2007-11-04T01:00:00.000-05:00", plus8.toString());
689
 
        DateTime plus9 = dt.plusHours(9);
690
 
        assertEquals("2007-11-04T02:00:00.000-05:00", plus9.toString());
691
 
    }
692
 
 
693
 
    public void test_DateTime_minusHour_NewYork_Autumn() {
694
 
        DateTime dt = new DateTime(2007, 11, 4, 8, 0, 0, 0, ZONE_NEW_YORK);
695
 
        assertEquals("2007-11-04T08:00:00.000-05:00", dt.toString());
696
 
        
697
 
        DateTime minus6 = dt.minusHours(6);
698
 
        assertEquals("2007-11-04T02:00:00.000-05:00", minus6.toString());
699
 
        DateTime minus7 = dt.minusHours(7);
700
 
        assertEquals("2007-11-04T01:00:00.000-05:00", minus7.toString());
701
 
        DateTime minus8 = dt.minusHours(8);
702
 
        assertEquals("2007-11-04T01:00:00.000-04:00", minus8.toString());
703
 
        DateTime minus9 = dt.minusHours(9);
704
 
        assertEquals("2007-11-04T00:00:00.000-04:00", minus9.toString());
705
 
    }
706
 
 
707
 
    //-----------------------------------------------------------------------
708
 
    public void test_DateTime_roundFloor_day_NewYork_Autumn_preCutover() {
709
 
        DateTime dt = new DateTime(2007, 11, 4, 1, 30, 0, 0, ZONE_NEW_YORK);
710
 
        assertEquals("2007-11-04T01:30:00.000-04:00", dt.toString());
711
 
        DateTime rounded = dt.dayOfMonth().roundFloorCopy();
712
 
        assertEquals("2007-11-04T00:00:00.000-04:00", rounded.toString());
713
 
    }
714
 
 
715
 
    public void test_DateTime_roundFloor_day_NewYork_Autumn_postCutover() {
716
 
        DateTime dt = new DateTime(2007, 11, 4, 1, 30, 0, 0, ZONE_NEW_YORK).plusHours(1);
717
 
        assertEquals("2007-11-04T01:30:00.000-05:00", dt.toString());
718
 
        DateTime rounded = dt.dayOfMonth().roundFloorCopy();
719
 
        assertEquals("2007-11-04T00:00:00.000-04:00", rounded.toString());
720
 
    }
721
 
 
722
 
    public void test_DateTime_roundFloor_hourOfDay_NewYork_Autumn_preCutover() {
723
 
        DateTime dt = new DateTime(2007, 11, 4, 1, 30, 0, 0, ZONE_NEW_YORK);
724
 
        assertEquals("2007-11-04T01:30:00.000-04:00", dt.toString());
725
 
        DateTime rounded = dt.hourOfDay().roundFloorCopy();
726
 
        assertEquals("2007-11-04T01:00:00.000-04:00", rounded.toString());
727
 
    }
728
 
 
729
 
    public void test_DateTime_roundFloor_hourOfDay_NewYork_Autumn_postCutover() {
730
 
        DateTime dt = new DateTime(2007, 11, 4, 1, 30, 0, 0, ZONE_NEW_YORK).plusHours(1);
731
 
        assertEquals("2007-11-04T01:30:00.000-05:00", dt.toString());
732
 
        DateTime rounded = dt.hourOfDay().roundFloorCopy();
733
 
        assertEquals("2007-11-04T01:00:00.000-05:00", rounded.toString());
734
 
    }
735
 
 
736
 
    public void test_DateTime_roundFloor_minuteOfHour_NewYork_Autumn_preCutover() {
737
 
        DateTime dt = new DateTime(2007, 11, 4, 1, 30, 40, 0, ZONE_NEW_YORK);
738
 
        assertEquals("2007-11-04T01:30:40.000-04:00", dt.toString());
739
 
        DateTime rounded = dt.minuteOfHour().roundFloorCopy();
740
 
        assertEquals("2007-11-04T01:30:00.000-04:00", rounded.toString());
741
 
    }
742
 
 
743
 
    public void test_DateTime_roundFloor_minuteOfHour_NewYork_Autumn_postCutover() {
744
 
        DateTime dt = new DateTime(2007, 11, 4, 1, 30, 40, 0, ZONE_NEW_YORK).plusHours(1);
745
 
        assertEquals("2007-11-04T01:30:40.000-05:00", dt.toString());
746
 
        DateTime rounded = dt.minuteOfHour().roundFloorCopy();
747
 
        assertEquals("2007-11-04T01:30:00.000-05:00", rounded.toString());
748
 
    }
749
 
 
750
 
    public void test_DateTime_roundFloor_secondOfMinute_NewYork_Autumn_preCutover() {
751
 
        DateTime dt = new DateTime(2007, 11, 4, 1, 30, 40, 500, ZONE_NEW_YORK);
752
 
        assertEquals("2007-11-04T01:30:40.500-04:00", dt.toString());
753
 
        DateTime rounded = dt.secondOfMinute().roundFloorCopy();
754
 
        assertEquals("2007-11-04T01:30:40.000-04:00", rounded.toString());
755
 
    }
756
 
 
757
 
    public void test_DateTime_roundFloor_secondOfMinute_NewYork_Autumn_postCutover() {
758
 
        DateTime dt = new DateTime(2007, 11, 4, 1, 30, 40, 500, ZONE_NEW_YORK).plusHours(1);
759
 
        assertEquals("2007-11-04T01:30:40.500-05:00", dt.toString());
760
 
        DateTime rounded = dt.secondOfMinute().roundFloorCopy();
761
 
        assertEquals("2007-11-04T01:30:40.000-05:00", rounded.toString());
762
 
    }
763
 
 
764
 
    //-----------------------------------------------------------------------
765
 
    public void test_DateTime_roundCeiling_day_NewYork_Autumn_preCutover() {
766
 
        DateTime dt = new DateTime(2007, 11, 4, 1, 30, 0, 0, ZONE_NEW_YORK);
767
 
        assertEquals("2007-11-04T01:30:00.000-04:00", dt.toString());
768
 
        DateTime rounded = dt.dayOfMonth().roundCeilingCopy();
769
 
        assertEquals("2007-11-05T00:00:00.000-05:00", rounded.toString());
770
 
    }
771
 
 
772
 
    public void test_DateTime_roundCeiling_day_NewYork_Autumn_postCutover() {
773
 
        DateTime dt = new DateTime(2007, 11, 4, 1, 30, 0, 0, ZONE_NEW_YORK).plusHours(1);
774
 
        assertEquals("2007-11-04T01:30:00.000-05:00", dt.toString());
775
 
        DateTime rounded = dt.dayOfMonth().roundCeilingCopy();
776
 
        assertEquals("2007-11-05T00:00:00.000-05:00", rounded.toString());
777
 
    }
778
 
 
779
 
    public void test_DateTime_roundCeiling_hourOfDay_NewYork_Autumn_preCutover() {
780
 
        DateTime dt = new DateTime(2007, 11, 4, 1, 30, 0, 0, ZONE_NEW_YORK);
781
 
        assertEquals("2007-11-04T01:30:00.000-04:00", dt.toString());
782
 
        DateTime rounded = dt.hourOfDay().roundCeilingCopy();
783
 
        assertEquals("2007-11-04T01:00:00.000-05:00", rounded.toString());
784
 
    }
785
 
 
786
 
    public void test_DateTime_roundCeiling_hourOfDay_NewYork_Autumn_postCutover() {
787
 
        DateTime dt = new DateTime(2007, 11, 4, 1, 30, 0, 0, ZONE_NEW_YORK).plusHours(1);
788
 
        assertEquals("2007-11-04T01:30:00.000-05:00", dt.toString());
789
 
        DateTime rounded = dt.hourOfDay().roundCeilingCopy();
790
 
        assertEquals("2007-11-04T02:00:00.000-05:00", rounded.toString());
791
 
    }
792
 
 
793
 
    public void test_DateTime_roundCeiling_minuteOfHour_NewYork_Autumn_preCutover() {
794
 
        DateTime dt = new DateTime(2007, 11, 4, 1, 30, 40, 0, ZONE_NEW_YORK);
795
 
        assertEquals("2007-11-04T01:30:40.000-04:00", dt.toString());
796
 
        DateTime rounded = dt.minuteOfHour().roundCeilingCopy();
797
 
        assertEquals("2007-11-04T01:31:00.000-04:00", rounded.toString());
798
 
    }
799
 
 
800
 
    public void test_DateTime_roundCeiling_minuteOfHour_NewYork_Autumn_postCutover() {
801
 
        DateTime dt = new DateTime(2007, 11, 4, 1, 30, 40, 0, ZONE_NEW_YORK).plusHours(1);
802
 
        assertEquals("2007-11-04T01:30:40.000-05:00", dt.toString());
803
 
        DateTime rounded = dt.minuteOfHour().roundCeilingCopy();
804
 
        assertEquals("2007-11-04T01:31:00.000-05:00", rounded.toString());
805
 
    }
806
 
 
807
 
    public void test_DateTime_roundCeiling_secondOfMinute_NewYork_Autumn_preCutover() {
808
 
        DateTime dt = new DateTime(2007, 11, 4, 1, 30, 40, 500, ZONE_NEW_YORK);
809
 
        assertEquals("2007-11-04T01:30:40.500-04:00", dt.toString());
810
 
        DateTime rounded = dt.secondOfMinute().roundCeilingCopy();
811
 
        assertEquals("2007-11-04T01:30:41.000-04:00", rounded.toString());
812
 
    }
813
 
 
814
 
    public void test_DateTime_roundCeiling_secondOfMinute_NewYork_Autumn_postCutover() {
815
 
        DateTime dt = new DateTime(2007, 11, 4, 1, 30, 40, 500, ZONE_NEW_YORK).plusHours(1);
816
 
        assertEquals("2007-11-04T01:30:40.500-05:00", dt.toString());
817
 
        DateTime rounded = dt.secondOfMinute().roundCeilingCopy();
818
 
        assertEquals("2007-11-04T01:30:41.000-05:00", rounded.toString());
819
 
    }
820
 
 
821
 
    //-----------------------------------------------------------------------
822
 
    /** Europe/Moscow cutover from 01:59 to 03:00 on 2007-03-25 */
823
 
    private static long CUTOVER_MOSCOW_SPRING = 1174777200000L;  // 2007-03-25T03:00:00.000+04:00
824
 
    private static final DateTimeZone ZONE_MOSCOW = DateTimeZone.forID("Europe/Moscow");
825
 
 
826
 
    //-----------------------------------------------------------------------
827
 
    public void test_MoscowIsCorrect_Spring() {
828
 
//      DateTime x = new DateTime(2007, 7, 1, 0, 0, 0, 0, ZONE_MOSCOW);
829
 
//      System.out.println(ZONE_MOSCOW.nextTransition(x.getMillis()));
830
 
//      DateTime y = new DateTime(ZONE_MOSCOW.nextTransition(x.getMillis()), ZONE_MOSCOW);
831
 
//      System.out.println(y);
832
 
        DateTime pre = new DateTime(CUTOVER_MOSCOW_SPRING - 1L, ZONE_MOSCOW);
833
 
        assertEquals("2007-03-25T01:59:59.999+03:00", pre.toString());
834
 
        DateTime at = new DateTime(CUTOVER_MOSCOW_SPRING, ZONE_MOSCOW);
835
 
        assertEquals("2007-03-25T03:00:00.000+04:00", at.toString());
836
 
        DateTime post = new DateTime(CUTOVER_MOSCOW_SPRING + 1L, ZONE_MOSCOW);
837
 
        assertEquals("2007-03-25T03:00:00.001+04:00", post.toString());
838
 
    }
839
 
 
840
 
    public void test_getOffsetFromLocal_Moscow_Spring() {
841
 
        doTest_getOffsetFromLocal(3, 25, 1, 0, "2007-03-25T01:00:00.000+03:00", ZONE_MOSCOW);
842
 
        doTest_getOffsetFromLocal(3, 25, 1,30, "2007-03-25T01:30:00.000+03:00", ZONE_MOSCOW);
843
 
        
844
 
        doTest_getOffsetFromLocal(3, 25, 2, 0, "2007-03-25T03:00:00.000+04:00", ZONE_MOSCOW);
845
 
        doTest_getOffsetFromLocal(3, 25, 2,30, "2007-03-25T03:30:00.000+04:00", ZONE_MOSCOW);
846
 
        
847
 
        doTest_getOffsetFromLocal(3, 25, 3, 0, "2007-03-25T03:00:00.000+04:00", ZONE_MOSCOW);
848
 
        doTest_getOffsetFromLocal(3, 25, 3,30, "2007-03-25T03:30:00.000+04:00", ZONE_MOSCOW);
849
 
        doTest_getOffsetFromLocal(3, 25, 4, 0, "2007-03-25T04:00:00.000+04:00", ZONE_MOSCOW);
850
 
        doTest_getOffsetFromLocal(3, 25, 5, 0, "2007-03-25T05:00:00.000+04:00", ZONE_MOSCOW);
851
 
        doTest_getOffsetFromLocal(3, 25, 6, 0, "2007-03-25T06:00:00.000+04:00", ZONE_MOSCOW);
852
 
        doTest_getOffsetFromLocal(3, 25, 7, 0, "2007-03-25T07:00:00.000+04:00", ZONE_MOSCOW);
853
 
        doTest_getOffsetFromLocal(3, 25, 8, 0, "2007-03-25T08:00:00.000+04:00", ZONE_MOSCOW);
854
 
    }
855
 
 
856
 
    public void test_DateTime_setHourAcross_Moscow_Spring() {
857
 
        DateTime dt = new DateTime(2007, 3, 25, 0, 0, 0, 0, ZONE_MOSCOW);
858
 
        assertEquals("2007-03-25T00:00:00.000+03:00", dt.toString());
859
 
        DateTime res = dt.hourOfDay().setCopy(4);
860
 
        assertEquals("2007-03-25T04:00:00.000+04:00", res.toString());
861
 
    }
862
 
 
863
 
    public void test_DateTime_setHourForward_Moscow_Spring() {
864
 
        DateTime dt = new DateTime(2007, 3, 25, 0, 0, 0, 0, ZONE_MOSCOW);
865
 
        assertEquals("2007-03-25T00:00:00.000+03:00", dt.toString());
866
 
        
867
 
        try {
868
 
            dt.hourOfDay().setCopy(2);
869
 
            fail();
870
 
        } catch (IllegalFieldValueException ex) {
871
 
            // expected
872
 
        }
873
 
    }
874
 
 
875
 
    public void test_DateTime_setHourBack_Moscow_Spring() {
876
 
        DateTime dt = new DateTime(2007, 3, 25, 8, 0, 0, 0, ZONE_MOSCOW);
877
 
        assertEquals("2007-03-25T08:00:00.000+04:00", dt.toString());
878
 
        
879
 
        try {
880
 
            dt.hourOfDay().setCopy(2);
881
 
            fail();
882
 
        } catch (IllegalFieldValueException ex) {
883
 
            // expected
884
 
        }
885
 
    }
886
 
 
887
 
    //-----------------------------------------------------------------------
888
 
    /** America/New_York cutover from 02:59 to 02:00 on 2007-10-28 */
889
 
    private static long CUTOVER_MOSCOW_AUTUMN = 1193526000000L;  // 2007-10-28T02:00:00.000+03:00
890
 
 
891
 
    //-----------------------------------------------------------------------
892
 
    public void test_MoscowIsCorrect_Autumn() {
893
 
        DateTime pre = new DateTime(CUTOVER_MOSCOW_AUTUMN - 1L, ZONE_MOSCOW);
894
 
        assertEquals("2007-10-28T02:59:59.999+04:00", pre.toString());
895
 
        DateTime at = new DateTime(CUTOVER_MOSCOW_AUTUMN, ZONE_MOSCOW);
896
 
        assertEquals("2007-10-28T02:00:00.000+03:00", at.toString());
897
 
        DateTime post = new DateTime(CUTOVER_MOSCOW_AUTUMN + 1L, ZONE_MOSCOW);
898
 
        assertEquals("2007-10-28T02:00:00.001+03:00", post.toString());
899
 
    }
900
 
 
901
 
    // broken, and getOffsetFromLocal has no obvious way to determine which is correct
902
 
//    public void test_getOffsetFromLocal_Moscow_Autumn() {
903
 
//        doTest_getOffsetFromLocal(10, 28, 0, 0, "2007-10-28T00:00:00.000+04:00", ZONE_MOSCOW);
904
 
//        doTest_getOffsetFromLocal(10, 28, 0,30, "2007-10-28T00:30:00.000+04:00", ZONE_MOSCOW);
905
 
//        doTest_getOffsetFromLocal(10, 28, 1, 0, "2007-10-28T01:00:00.000+04:00", ZONE_MOSCOW);
906
 
//        doTest_getOffsetFromLocal(10, 28, 1,30, "2007-10-28T01:30:00.000+04:00", ZONE_MOSCOW);
907
 
//        
908
 
//        doTest_getOffsetFromLocal(10, 28, 2, 0, "2007-10-28T02:00:00.000+04:00", ZONE_MOSCOW);
909
 
//        doTest_getOffsetFromLocal(10, 28, 2,30, "2007-10-28T02:30:00.000+04:00", ZONE_MOSCOW);
910
 
//        
911
 
//        doTest_getOffsetFromLocal(10, 28, 3, 0, "2007-10-28T03:00:00.000+03:00", ZONE_MOSCOW);
912
 
//        doTest_getOffsetFromLocal(10, 28, 3,30, "2007-10-28T03:30:00.000+03:00", ZONE_MOSCOW);
913
 
//        doTest_getOffsetFromLocal(10, 28, 4, 0, "2007-10-28T04:00:00.000+03:00", ZONE_MOSCOW);
914
 
//        doTest_getOffsetFromLocal(10, 28, 5, 0, "2007-10-28T05:00:00.000+03:00", ZONE_MOSCOW);
915
 
//        doTest_getOffsetFromLocal(10, 28, 6, 0, "2007-10-28T06:00:00.000+03:00", ZONE_MOSCOW);
916
 
//        doTest_getOffsetFromLocal(10, 28, 7, 0, "2007-10-28T07:00:00.000+03:00", ZONE_MOSCOW);
917
 
//        doTest_getOffsetFromLocal(10, 28, 8, 0, "2007-10-28T08:00:00.000+03:00", ZONE_MOSCOW);
918
 
//    }
919
 
 
920
 
    public void test_DateTime_plusHour_Moscow_Autumn() {
921
 
        DateTime dt = new DateTime(2007, 10, 27, 19, 0, 0, 0, ZONE_MOSCOW);
922
 
        assertEquals("2007-10-27T19:00:00.000+04:00", dt.toString());
923
 
        
924
 
        DateTime plus6 = dt.plusHours(6);
925
 
        assertEquals("2007-10-28T01:00:00.000+04:00", plus6.toString());
926
 
        DateTime plus7 = dt.plusHours(7);
927
 
        assertEquals("2007-10-28T02:00:00.000+04:00", plus7.toString());
928
 
        DateTime plus8 = dt.plusHours(8);
929
 
        assertEquals("2007-10-28T02:00:00.000+03:00", plus8.toString());
930
 
        DateTime plus9 = dt.plusHours(9);
931
 
        assertEquals("2007-10-28T03:00:00.000+03:00", plus9.toString());
932
 
    }
933
 
 
934
 
    public void test_DateTime_minusHour_Moscow_Autumn() {
935
 
        DateTime dt = new DateTime(2007, 10, 28, 9, 0, 0, 0, ZONE_MOSCOW);
936
 
        assertEquals("2007-10-28T09:00:00.000+03:00", dt.toString());
937
 
        
938
 
        DateTime minus6 = dt.minusHours(6);
939
 
        assertEquals("2007-10-28T03:00:00.000+03:00", minus6.toString());
940
 
        DateTime minus7 = dt.minusHours(7);
941
 
        assertEquals("2007-10-28T02:00:00.000+03:00", minus7.toString());
942
 
        DateTime minus8 = dt.minusHours(8);
943
 
        assertEquals("2007-10-28T02:00:00.000+04:00", minus8.toString());
944
 
        DateTime minus9 = dt.minusHours(9);
945
 
        assertEquals("2007-10-28T01:00:00.000+04:00", minus9.toString());
946
 
    }
947
 
 
948
 
    //-----------------------------------------------------------------------
949
 
    //-----------------------------------------------------------------------
950
 
    //-----------------------------------------------------------------------
951
 
    /** America/Guatemala cutover from 23:59 to 23:00 on 2006-09-30 */
952
 
    private static long CUTOVER_GUATEMALA_AUTUMN = 1159678800000L; // 2006-09-30T23:00:00.000-06:00
953
 
    private static final DateTimeZone ZONE_GUATEMALA = DateTimeZone.forID("America/Guatemala");
954
 
 
955
 
    //-----------------------------------------------------------------------
956
 
    public void test_GuatemataIsCorrect_Autumn() {
957
 
        DateTime pre = new DateTime(CUTOVER_GUATEMALA_AUTUMN - 1L, ZONE_GUATEMALA);
958
 
        assertEquals("2006-09-30T23:59:59.999-05:00", pre.toString());
959
 
        DateTime at = new DateTime(CUTOVER_GUATEMALA_AUTUMN, ZONE_GUATEMALA);
960
 
        assertEquals("2006-09-30T23:00:00.000-06:00", at.toString());
961
 
        DateTime post = new DateTime(CUTOVER_GUATEMALA_AUTUMN + 1L, ZONE_GUATEMALA);
962
 
        assertEquals("2006-09-30T23:00:00.001-06:00", post.toString());
963
 
    }
964
 
 
965
 
    public void test_getOffsetFromLocal_Guatemata_Autumn() {
966
 
        doTest_getOffsetFromLocal( 2006, 9,30,23, 0,
967
 
                                  "2006-09-30T23:00:00.000-05:00", ZONE_GUATEMALA);
968
 
        doTest_getOffsetFromLocal( 2006, 9,30,23,30,
969
 
                                  "2006-09-30T23:30:00.000-05:00", ZONE_GUATEMALA);
970
 
        
971
 
        doTest_getOffsetFromLocal( 2006, 9,30,23, 0,
972
 
                                  "2006-09-30T23:00:00.000-05:00", ZONE_GUATEMALA);
973
 
        doTest_getOffsetFromLocal( 2006, 9,30,23,30,
974
 
                                  "2006-09-30T23:30:00.000-05:00", ZONE_GUATEMALA);
975
 
        
976
 
        doTest_getOffsetFromLocal( 2006,10, 1, 0, 0,
977
 
                                  "2006-10-01T00:00:00.000-06:00", ZONE_GUATEMALA);
978
 
        doTest_getOffsetFromLocal( 2006,10, 1, 0,30,
979
 
                                  "2006-10-01T00:30:00.000-06:00", ZONE_GUATEMALA);
980
 
        doTest_getOffsetFromLocal( 2006,10, 1, 1, 0,
981
 
                                  "2006-10-01T01:00:00.000-06:00", ZONE_GUATEMALA);
982
 
        doTest_getOffsetFromLocal( 2006,10, 1, 1,30,
983
 
                                  "2006-10-01T01:30:00.000-06:00", ZONE_GUATEMALA);
984
 
        doTest_getOffsetFromLocal( 2006,10, 1, 2, 0,
985
 
                                  "2006-10-01T02:00:00.000-06:00", ZONE_GUATEMALA);
986
 
        doTest_getOffsetFromLocal( 2006,10, 1, 2,30,
987
 
                                  "2006-10-01T02:30:00.000-06:00", ZONE_GUATEMALA);
988
 
        doTest_getOffsetFromLocal( 2006,10, 1, 3, 0,
989
 
                                  "2006-10-01T03:00:00.000-06:00", ZONE_GUATEMALA);
990
 
        doTest_getOffsetFromLocal( 2006,10, 1, 3,30,
991
 
                                  "2006-10-01T03:30:00.000-06:00", ZONE_GUATEMALA);
992
 
        doTest_getOffsetFromLocal( 2006,10, 1, 4, 0,
993
 
                                  "2006-10-01T04:00:00.000-06:00", ZONE_GUATEMALA);
994
 
        doTest_getOffsetFromLocal( 2006,10, 1, 4,30,
995
 
                                  "2006-10-01T04:30:00.000-06:00", ZONE_GUATEMALA);
996
 
        doTest_getOffsetFromLocal( 2006,10, 1, 5, 0,
997
 
                                  "2006-10-01T05:00:00.000-06:00", ZONE_GUATEMALA);
998
 
        doTest_getOffsetFromLocal( 2006,10, 1, 5,30,
999
 
                                  "2006-10-01T05:30:00.000-06:00", ZONE_GUATEMALA);
1000
 
        doTest_getOffsetFromLocal( 2006,10, 1, 6, 0,
1001
 
                                  "2006-10-01T06:00:00.000-06:00", ZONE_GUATEMALA);
1002
 
        doTest_getOffsetFromLocal( 2006,10, 1, 6,30,
1003
 
                                  "2006-10-01T06:30:00.000-06:00", ZONE_GUATEMALA);
1004
 
    }
1005
 
 
1006
 
    public void test_DateTime_plusHour_Guatemata_Autumn() {
1007
 
        DateTime dt = new DateTime(2006, 9, 30, 20, 0, 0, 0, ZONE_GUATEMALA);
1008
 
        assertEquals("2006-09-30T20:00:00.000-05:00", dt.toString());
1009
 
        
1010
 
        DateTime plus1 = dt.plusHours(1);
1011
 
        assertEquals("2006-09-30T21:00:00.000-05:00", plus1.toString());
1012
 
        DateTime plus2 = dt.plusHours(2);
1013
 
        assertEquals("2006-09-30T22:00:00.000-05:00", plus2.toString());
1014
 
        DateTime plus3 = dt.plusHours(3);
1015
 
        assertEquals("2006-09-30T23:00:00.000-05:00", plus3.toString());
1016
 
        DateTime plus4 = dt.plusHours(4);
1017
 
        assertEquals("2006-09-30T23:00:00.000-06:00", plus4.toString());
1018
 
        DateTime plus5 = dt.plusHours(5);
1019
 
        assertEquals("2006-10-01T00:00:00.000-06:00", plus5.toString());
1020
 
        DateTime plus6 = dt.plusHours(6);
1021
 
        assertEquals("2006-10-01T01:00:00.000-06:00", plus6.toString());
1022
 
        DateTime plus7 = dt.plusHours(7);
1023
 
        assertEquals("2006-10-01T02:00:00.000-06:00", plus7.toString());
1024
 
    }
1025
 
 
1026
 
    public void test_DateTime_minusHour_Guatemata_Autumn() {
1027
 
        DateTime dt = new DateTime(2006, 10, 1, 2, 0, 0, 0, ZONE_GUATEMALA);
1028
 
        assertEquals("2006-10-01T02:00:00.000-06:00", dt.toString());
1029
 
        
1030
 
        DateTime minus1 = dt.minusHours(1);
1031
 
        assertEquals("2006-10-01T01:00:00.000-06:00", minus1.toString());
1032
 
        DateTime minus2 = dt.minusHours(2);
1033
 
        assertEquals("2006-10-01T00:00:00.000-06:00", minus2.toString());
1034
 
        DateTime minus3 = dt.minusHours(3);
1035
 
        assertEquals("2006-09-30T23:00:00.000-06:00", minus3.toString());
1036
 
        DateTime minus4 = dt.minusHours(4);
1037
 
        assertEquals("2006-09-30T23:00:00.000-05:00", minus4.toString());
1038
 
        DateTime minus5 = dt.minusHours(5);
1039
 
        assertEquals("2006-09-30T22:00:00.000-05:00", minus5.toString());
1040
 
        DateTime minus6 = dt.minusHours(6);
1041
 
        assertEquals("2006-09-30T21:00:00.000-05:00", minus6.toString());
1042
 
        DateTime minus7 = dt.minusHours(7);
1043
 
        assertEquals("2006-09-30T20:00:00.000-05:00", minus7.toString());
1044
 
    }
1045
 
 
1046
 
    //-----------------------------------------------------------------------
1047
 
    //-----------------------------------------------------------------------
1048
 
    //-----------------------------------------------------------------------
1049
 
 
1050
 
//    public void test_toDateMidnight_SaoPaolo() {
1051
 
//        // RFE: 1684259
1052
 
//        DateTimeZone zone = DateTimeZone.forID("America/Sao_Paulo");
1053
 
//        LocalDate baseDate = new LocalDate(2006, 11, 5);
1054
 
//        DateMidnight dm = baseDate.toDateMidnight(zone);
1055
 
//        assertEquals("2006-11-05T00:00:00.000-03:00", dm.toString());
1056
 
//        DateTime dt = baseDate.toDateTimeAtMidnight(zone);
1057
 
//        assertEquals("2006-11-05T00:00:00.000-03:00", dt.toString());
1058
 
//    }
1059
 
 
1060
 
    //-----------------------------------------------------------------------
1061
 
    //-----------------------------------------------------------------------
1062
 
    //-----------------------------------------------------------------------
1063
 
    private void doTest_getOffsetFromLocal(int month, int day, int hour, int min,
1064
 
                                           String expected, DateTimeZone zone)
1065
 
    {
1066
 
        doTest_getOffsetFromLocal(2007, month, day, hour, min, expected, zone);
1067
 
    }
1068
 
 
1069
 
    private void doTest_getOffsetFromLocal(int year, int month, int day, int hour, int min,
1070
 
                                           String expected, DateTimeZone zone)
1071
 
    {
1072
 
        DateTime dt = new DateTime(year, month, day, hour, min, 0, 0, DateTimeZone.UTC);
1073
 
        int offset = zone.getOffsetFromLocal(dt.getMillis());
1074
 
        DateTime res = new DateTime(dt.getMillis() - offset, zone);
1075
 
        assertEquals(res.toString(), expected, res.toString());
1076
 
    }
1077
 
 
1078
 
}