View Javadoc

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   * @author ocleirig
14   * 
15   * This tests that the DateUtility class works properly.
16   *
17   */
18  public class TestTimeZoneAdjustingDateFormatter extends TestCase {
19  
20  	/**
21  	 * 
22  	 */
23  	public TestTimeZoneAdjustingDateFormatter() {
24  		// TODO Auto-generated constructor stub
25  	}
26  
27  	/**
28  	 * @param name
29  	 */
30  	public TestTimeZoneAdjustingDateFormatter(String name) {
31  		super(name);
32  		// TODO Auto-generated constructor stub
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  		// 1 pm UTC should be 9 AM EDT
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  		// 1 pm pacific time should be 4 pm Eastern time
49  		assertEquals("2012-08-15 16:00 EDT", formatted);
50  				
51  				
52  		
53  	}
54  
55  }