import java.text.DateFormat;
import java.util.List;
import java.util.Locale;
+import java.util.TimeZone;
import junit.framework.TestCase;
public void testAttachmentDetails() throws Exception {
List<Attachment> attachments = quick.getAttachments();
- // Pick a predictable date format
- // Note that the 28th April is in summer time in the UK
+ // Pick a predictable date format + timezone
DateFormat fmt = DateFormat.getDateTimeInstance(
DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK
);
+ fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
// They should all have the same date on them
- assertEquals("28-Apr-2010 13:40:56", fmt.format( attachments.get(0).getModifiedDate()));
- assertEquals("28-Apr-2010 13:40:56", fmt.format( attachments.get(1).getModifiedDate()));
- assertEquals("28-Apr-2010 13:40:56", fmt.format( attachments.get(2).getModifiedDate()));
- assertEquals("28-Apr-2010 13:40:56", fmt.format( attachments.get(3).getModifiedDate()));
- assertEquals("28-Apr-2010 13:40:56", fmt.format( attachments.get(4).getModifiedDate()));
+ assertEquals("28-Apr-2010 12:40:56", fmt.format( attachments.get(0).getModifiedDate()));
+ assertEquals("28-Apr-2010 12:40:56", fmt.format( attachments.get(1).getModifiedDate()));
+ assertEquals("28-Apr-2010 12:40:56", fmt.format( attachments.get(2).getModifiedDate()));
+ assertEquals("28-Apr-2010 12:40:56", fmt.format( attachments.get(3).getModifiedDate()));
+ assertEquals("28-Apr-2010 12:40:56", fmt.format( attachments.get(4).getModifiedDate()));
// They should all have a 3512 byte metafile rendered version
assertEquals(3512, attachments.get(0).getRenderedMetaFile().length);
import java.io.ByteArrayInputStream;
import java.text.DateFormat;
import java.util.Locale;
+import java.util.TimeZone;
import junit.framework.TestCase;
DateFormat fmt = DateFormat.getDateTimeInstance(
DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK
);
+ fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
assertEquals("15-Dec-2010 14:46:31", fmt.format(date.getDate()));
// RTF
import java.io.ByteArrayInputStream;
import java.text.DateFormat;
import java.util.Locale;
+import java.util.TimeZone;
import junit.framework.TestCase;
assertEquals(3, LittleEndian.getUShort(attr.getData(), 12)); // Weds
// Ask for it as a Java date, and have it converted
- // Pick a predictable format + location. Note location is in summer time!
+ // Pick a predictable format + location + timezone
TNEFDateAttribute date = (TNEFDateAttribute)attr;
DateFormat fmt = DateFormat.getDateTimeInstance(
DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK
);
- assertEquals("28-Apr-2010 13:40:56", fmt.format(date.getDate()));
+ fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
+ assertEquals("28-Apr-2010 12:40:56", fmt.format(date.getDate()));
}
/**