aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2011-03-04 11:06:59 +0000
committerNick Burch <nick@apache.org>2011-03-04 11:06:59 +0000
commitadcf6372926fd869f76e6ca4b868b8f628a218ca (patch)
treec5f3edf92b05349e9a6590c101a5e1dd3883b4be /src
parentb8a97d2b3faac38ea37fb3094b3d9e192fa78f37 (diff)
downloadpoi-adcf6372926fd869f76e6ca4b868b8f628a218ca.tar.gz
poi-adcf6372926fd869f76e6ca4b868b8f628a218ca.zip
Setting the locale doesn't seem to set the timezone, so do that explicitly to ensure the tests behave for everyone
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1077874 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hmef/TestAttachments.java15
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java2
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestTNEFAttributes.java6
3 files changed, 14 insertions, 9 deletions
diff --git a/src/scratchpad/testcases/org/apache/poi/hmef/TestAttachments.java b/src/scratchpad/testcases/org/apache/poi/hmef/TestAttachments.java
index 0e89f46a10..79582b1f08 100644
--- a/src/scratchpad/testcases/org/apache/poi/hmef/TestAttachments.java
+++ b/src/scratchpad/testcases/org/apache/poi/hmef/TestAttachments.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.text.DateFormat;
import java.util.List;
import java.util.Locale;
+import java.util.TimeZone;
import junit.framework.TestCase;
@@ -87,18 +88,18 @@ public final class TestAttachments extends 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);
diff --git a/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java b/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java
index 60655a4ddd..ca8b41feee 100644
--- a/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java
+++ b/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java
@@ -20,6 +20,7 @@ package org.apache.poi.hmef.attribute;
import java.io.ByteArrayInputStream;
import java.text.DateFormat;
import java.util.Locale;
+import java.util.TimeZone;
import junit.framework.TestCase;
@@ -151,6 +152,7 @@ public final class TestMAPIAttributes extends 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
diff --git a/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestTNEFAttributes.java b/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestTNEFAttributes.java
index f7883dfed6..fcea77f02f 100644
--- a/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestTNEFAttributes.java
+++ b/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestTNEFAttributes.java
@@ -20,6 +20,7 @@ package org.apache.poi.hmef.attribute;
import java.io.ByteArrayInputStream;
import java.text.DateFormat;
import java.util.Locale;
+import java.util.TimeZone;
import junit.framework.TestCase;
@@ -156,12 +157,13 @@ public final class TestTNEFAttributes extends 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()));
}
/**