1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
29
30
31
32
33 public class TestTimeZoneAdjustingDateFormatter extends TestCase {
34
35
36
37
38 public TestTimeZoneAdjustingDateFormatter() {
39
40 }
41
42
43
44
45 public TestTimeZoneAdjustingDateFormatter(String name) {
46 super(name);
47
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
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
64 assertEquals("2012-08-15 16:00 EDT", formatted);
65
66
67
68 }
69
70 }