1 /**
2 * Copyright 2004-2014 The Kuali Foundation
3 *
4 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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 /**
17 *
18 */
19 package org.kuali.student.contract.model.util;
20
21 import org.joda.time.DateTime;
22 import org.joda.time.DateTimeZone;
23 import org.joda.time.tz.DateTimeZoneBuilder;
24
25 import junit.framework.TestCase;
26
27 /**
28 * @author ocleirig
29 *
30 * This tests that the DateUtility class works properly.
31 *
32 */
33 public class TestTimeZoneAdjustingDateFormatter extends TestCase {
34
35 /**
36 *
37 */
38 public TestTimeZoneAdjustingDateFormatter() {
39 // TODO Auto-generated constructor stub
40 }
41
42 /**
43 * @param name
44 */
45 public TestTimeZoneAdjustingDateFormatter(String name) {
46 super(name);
47 // TODO Auto-generated constructor stub
48 }
49
50 public void testConvertUTCToEastern() {
51
52 DateTime utcTime = new DateTime(DateTimeZone.UTC).withDate(2012, 8, 15).withTime(13, 0, 0, 0);
53
54 String formatted = DateUtility.asYMDHMInEasternTimeZone(utcTime);
55
56 // 1 pm UTC should be 9 AM EDT
57 assertEquals("2012-08-15 09:00 EDT", formatted);
58
59 DateTime pacificTime = utcTime.withZoneRetainFields(DateTimeZone.forID("America/Los_Angeles"));
60
61 formatted = DateUtility.asYMDHMInEasternTimeZone(pacificTime);
62
63 // 1 pm pacific time should be 4 pm Eastern time
64 assertEquals("2012-08-15 16:00 EDT", formatted);
65
66
67
68 }
69
70 }