You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2003/09/05 03:35:48 UTC

cvs commit: incubator-geronimo/specs/javamail/src/test/javax/mail/internet MailDateFormatTest.java

dain        2003/09/04 18:35:48

  Modified:    specs/javamail/src/test/javax/mail/internet
                        MailDateFormatTest.java
  Log:
  Fixed test failure.
  When the date is parsed and converted into a Date object the timezone is lost, so
  later when the calendar is created it is created in the machine local timezone.  To
  fix this I explicitly set the timezone on the calendar.
  
  Revision  Changes    Path
  1.2       +4 -2      incubator-geronimo/specs/javamail/src/test/javax/mail/internet/MailDateFormatTest.java
  
  Index: MailDateFormatTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/specs/javamail/src/test/javax/mail/internet/MailDateFormatTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MailDateFormatTest.java	4 Sep 2003 01:31:41 -0000	1.1
  +++ MailDateFormatTest.java	5 Sep 2003 01:35:48 -0000	1.2
  @@ -58,6 +58,8 @@
   import java.text.ParseException;
   import java.util.Calendar;
   import java.util.Date;
  +import java.util.Locale;
  +import java.util.SimpleTimeZone;
   
   import junit.framework.TestCase;
   
  @@ -69,7 +71,7 @@
           MailDateFormat mdf = new MailDateFormat();
           Date date = mdf.parse("Wed, 27 Aug 2003 13:43:38 +0100 (BST)");
           // don't we just love the Date class?
  -        Calendar cal = Calendar.getInstance();
  +        Calendar cal = Calendar.getInstance(new SimpleTimeZone(+1 * 60 * 60 * 1000, "BST"), Locale.getDefault());
           cal.setTime(date);
           assertEquals(2003, cal.get(Calendar.YEAR));
           assertEquals(Calendar.AUGUST, cal.get(Calendar.MONTH));