fixed failing tests, force UTC time zone when formatting dates
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1401641 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f6f8425c40
commit
04b9f9dff9
@ -18,6 +18,7 @@
|
||||
package org.apache.poi.hsmf.datatypes;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
@ -92,7 +93,7 @@ public class PropertyValue {
|
||||
long time = LittleEndian.getLong(data);
|
||||
time = (time / 10 / 1000) - OFFSET;
|
||||
|
||||
Calendar timeC = Calendar.getInstance();
|
||||
Calendar timeC = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
|
||||
timeC.setTimeInMillis(time);
|
||||
|
||||
return timeC;
|
||||
|
@ -20,6 +20,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.poi.POIOLE2TextExtractor;
|
||||
import org.apache.poi.hsmf.MAPIMessage;
|
||||
@ -117,6 +118,7 @@ public class OutlookTextExtactor extends POIOLE2TextExtractor {
|
||||
try {
|
||||
// First try via the proper chunk
|
||||
SimpleDateFormat f = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss Z");
|
||||
f.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
s.append("Date: " + f.format(msg.getMessageDate().getTime()) + "\n");
|
||||
} catch(ChunkNotFoundException e) {
|
||||
try {
|
||||
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@ -63,6 +64,7 @@ public final class TestOutlookTextExtractor extends TestCase {
|
||||
assertContains(text, "Subject: Test the content transformer\n");
|
||||
Calendar cal = new GregorianCalendar(2007, 5, 14, 9, 42, 55);
|
||||
SimpleDateFormat f = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss Z");
|
||||
f.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
String dateText = f.format(cal.getTime());
|
||||
assertContains(text, "Date: " + dateText + "\n");
|
||||
assertContains(text, "The quick brown fox jumps over the lazy dog");
|
||||
@ -81,7 +83,7 @@ public final class TestOutlookTextExtractor extends TestCase {
|
||||
assertEquals(-1, text.indexOf("CC:"));
|
||||
assertEquals(-1, text.indexOf("BCC:"));
|
||||
assertContains(text, "Subject: test message\n");
|
||||
assertContains(text, "Date: Fri, 6 Jul 2007 06:27:17 +0100\n");
|
||||
assertContains(text, "Date: Fri, 6 Jul 2007 05:27:17 +0000\n");
|
||||
assertContains(text, "This is a test message.");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user