1
2
3
4 package org.kuali.student.contract.model.util;
5
6 import org.joda.time.DateTime;
7 import org.joda.time.DateTimeZone;
8 import org.joda.time.tz.DateTimeZoneBuilder;
9
10 import junit.framework.TestCase;
11
12
13
14
15
16
17
18 public class TestTimeZoneAdjustingDateFormatter extends TestCase {
19
20
21
22
23 public TestTimeZoneAdjustingDateFormatter() {
24
25 }
26
27
28
29
30 public TestTimeZoneAdjustingDateFormatter(String name) {
31 super(name);
32
33 }
34
35 public void testConvertUTCToEastern() {
36
37 DateTime utcTime = new DateTime(DateTimeZone.UTC).withDate(2012, 8, 15).withTime(13, 0, 0, 0);
38
39 String formatted = DateUtility.asYMDHMInEasternTimeZone(utcTime);
40
41
42 assertEquals("2012-08-15 09:00 EDT", formatted);
43
44 DateTime pacificTime = utcTime.withZoneRetainFields(DateTimeZone.forID("America/Los_Angeles"));
45
46 formatted = DateUtility.asYMDHMInEasternTimeZone(pacificTime);
47
48
49 assertEquals("2012-08-15 16:00 EDT", formatted);
50
51
52
53 }
54
55 }