poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1701888 - in /poi/trunk/src: java/org/apache/poi/hssf/usermodel/ java/org/apache/poi/ss/format/ java/org/apache/poi/ss/usermodel/ ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/ ooxml/java/org/apache/poi/xssf/extractor/ ooxml/java/org/a...
Date Wed, 09 Sep 2015 00:41:03 GMT
Author: kiwiwings
Date: Wed Sep  9 00:41:03 2015
New Revision: 1701888

URL: http://svn.apache.org/r1701888
Log:
forbidden apis fixes - a few DateFormat clean ups ...

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/DVConstraint.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormatter.java
    poi/trunk/src/java/org/apache/poi/ss/format/CellDateFormatter.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
    poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/OOXMLSignatureFacet.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/TestAttachments.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestTNEFAttributes.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/DVConstraint.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/DVConstraint.java?rev=1701888&r1=1701887&r2=1701888&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/DVConstraint.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/DVConstraint.java Wed Sep  9 00:41:03
2015
@@ -20,7 +20,6 @@ package org.apache.poi.hssf.usermodel;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
-import java.util.Locale;
 import java.util.regex.Pattern;
 
 import org.apache.poi.hssf.model.HSSFFormulaParser;
@@ -32,6 +31,7 @@ import org.apache.poi.ss.formula.ptg.Num
 import org.apache.poi.ss.formula.ptg.Ptg;
 import org.apache.poi.ss.formula.ptg.StringPtg;
 import org.apache.poi.ss.usermodel.DataValidationConstraint;
+import org.apache.poi.util.LocaleUtil;
 
 /**
  * Data Validation Constraint
@@ -180,7 +180,11 @@ public class DVConstraint implements Dat
 			throw new IllegalArgumentException("expr1 must be supplied");
 		}
 		OperatorType.validateSecondArg(comparisonOperator, expr2);
-		SimpleDateFormat df = dateFormat == null ? null : new SimpleDateFormat(dateFormat, Locale.ROOT);
+		SimpleDateFormat df = null;
+		if (dateFormat != null) {
+		    df = new SimpleDateFormat(dateFormat, LocaleUtil.getUserLocale());
+		    df.setTimeZone(LocaleUtil.getUserTimeZone());
+		}
 		
 		// formula1 and value1 are mutually exclusive
 		String formula1 = getFormulaFromTextExpression(expr1);
@@ -392,7 +396,8 @@ public class DVConstraint implements Dat
 		return new FormulaPair(formula1, formula2);
 	}
 
-	private Ptg[] createListFormula(HSSFSheet sheet) {
+    @SuppressWarnings("resource")
+    private Ptg[] createListFormula(HSSFSheet sheet) {
 
 		if (_explicitListValues == null) {
             HSSFWorkbook wb = sheet.getWorkbook();
@@ -417,6 +422,7 @@ public class DVConstraint implements Dat
 	 * @return The parsed token array representing the formula or value specified. 
 	 * Empty array if both formula and value are <code>null</code>
 	 */
+    @SuppressWarnings("resource")
 	private static Ptg[] convertDoubleFormula(String formula, Double value, HSSFSheet sheet)
{
 		if (formula == null) {
 			if (value == null) {

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java?rev=1701888&r1=1701887&r2=1701888&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java Wed Sep  9 00:41:03 2015
@@ -17,7 +17,6 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
@@ -53,8 +52,6 @@ import org.apache.poi.ss.util.CellRangeA
 import org.apache.poi.ss.util.CellReference;
 import org.apache.poi.ss.util.NumberToTextConverter;
 import org.apache.poi.util.LocaleUtil;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
 
 /**
  * High level representation of a cell in a row of a spreadsheet.
@@ -69,8 +66,6 @@ import org.apache.poi.util.POILogger;
  * <p>
  */
 public class HSSFCell implements Cell {
-    private static POILogger log = POILogFactory.getLogger(HSSFCell.class);
-
     private static final String FILE_FORMAT_NAME  = "BIFF8";
     /**
      * The maximum  number of columns in BIFF8
@@ -990,7 +985,8 @@ public class HSSFCell implements Cell {
             case CELL_TYPE_NUMERIC:
                 //TODO apply the dataformat for this cell
                 if (HSSFDateUtil.isCellDateFormatted(this)) {
-                    DateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", LocaleUtil.getUserLocale());
+                    SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", LocaleUtil.getUserLocale());
+                    sdf.setTimeZone(LocaleUtil.getUserTimeZone());
                     return sdf.format(getDateCellValue());
                 }
 				return  String.valueOf(getNumericCellValue());

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormatter.java?rev=1701888&r1=1701887&r2=1701888&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormatter.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormatter.java Wed Sep  9 00:41:03
2015
@@ -19,7 +19,6 @@ package org.apache.poi.hssf.usermodel;
 
 import java.text.DecimalFormat;
 import java.text.Format;
-import java.text.SimpleDateFormat;
 import java.util.Locale;
 
 import org.apache.poi.ss.usermodel.DataFormatter;
@@ -33,7 +32,7 @@ import org.apache.poi.util.LocaleUtil;
  * codes, etc.
  * <p>
  * Internally, formats will be implemented using subclasses of {@link Format}
- * such as {@link DecimalFormat} and {@link SimpleDateFormat}. Therefore the
+ * such as {@link DecimalFormat} and {@link java.text.SimpleDateFormat}. Therefore the
  * formats used by this class must obey the same pattern rules as these Format
  * subclasses. This means that only legal number pattern characters ("0", "#",
  * ".", "," etc.) may appear in number formats. Other characters can be

Modified: poi/trunk/src/java/org/apache/poi/ss/format/CellDateFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/format/CellDateFormatter.java?rev=1701888&r1=1701887&r2=1701888&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/format/CellDateFormatter.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/format/CellDateFormatter.java Wed Sep  9 00:41:03
2015
@@ -38,17 +38,11 @@ public class CellDateFormatter extends C
     private final DateFormat dateFmt;
     private String sFmt;
 
-    private final long EXCEL_EPOCH_TIME;
-    private final Date EXCEL_EPOCH_DATE;
+    private final Calendar EXCEL_EPOCH_CAL =
+        LocaleUtil.getLocaleCalendar(1904, 0, 1);
 
     private static /* final */ CellDateFormatter SIMPLE_DATE = null;
 
-    {
-        Calendar c = LocaleUtil.getLocaleCalendar(1904, 0, 1, 0, 0, 0);
-        EXCEL_EPOCH_DATE = c.getTime();
-        EXCEL_EPOCH_TIME = c.getTimeInMillis();
-    }
-
     private class DatePartHandler implements CellFormatPart.PartHandler {
         private int mStart = -1;
         private int mLen;
@@ -153,6 +147,7 @@ public class CellDateFormatter extends C
         // See https://issues.apache.org/bugzilla/show_bug.cgi?id=53369
         String ptrn = descBuf.toString().replaceAll("((y)(?!y))(?<!yy)", "yy");
         dateFmt = new SimpleDateFormat(ptrn, LocaleUtil.getUserLocale());
+        dateFmt.setTimeZone(LocaleUtil.getUserTimeZone());
     }
 
     /** {@inheritDoc} */
@@ -161,15 +156,18 @@ public class CellDateFormatter extends C
             value = 0.0;
         if (value instanceof Number) {
             Number num = (Number) value;
-            double v = num.doubleValue();
-            if (v == 0.0)
-                value = EXCEL_EPOCH_DATE;
-            else
-                value = new Date((long) (EXCEL_EPOCH_TIME + v));
+            long v = num.longValue();
+            if (v == 0L) {
+                value = EXCEL_EPOCH_CAL.getTime();
+            } else {
+                Calendar c = (Calendar)EXCEL_EPOCH_CAL.clone();
+                c.add(Calendar.SECOND, (int)(v / 1000));
+                c.add(Calendar.MILLISECOND, (int)(v % 1000));
+                value = c.getTime();
+            }
         }
 
-        AttributedCharacterIterator it = dateFmt.formatToCharacterIterator(
-                value);
+        AttributedCharacterIterator it = dateFmt.formatToCharacterIterator(value);
         boolean doneAm = false;
         boolean doneMillis = false;
 
@@ -219,7 +217,7 @@ public class CellDateFormatter extends C
      */
     public void simpleValue(StringBuffer toAppendTo, Object value) {
         synchronized (CellDateFormatter.class) {
-            if (SIMPLE_DATE == null || !SIMPLE_DATE.EXCEL_EPOCH_DATE.equals(EXCEL_EPOCH_DATE))
{
+            if (SIMPLE_DATE == null || !SIMPLE_DATE.EXCEL_EPOCH_CAL.equals(EXCEL_EPOCH_CAL))
{
                 SIMPLE_DATE = new CellDateFormatter("mm/d/y");
             }
         }

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java?rev=1701888&r1=1701887&r2=1701888&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java Wed Sep  9 00:41:03
2015
@@ -28,7 +28,6 @@ import java.text.DecimalFormatSymbols;
 import java.text.FieldPosition;
 import java.text.Format;
 import java.text.ParsePosition;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -53,7 +52,7 @@ import org.apache.poi.util.LocaleUtil;
  * codes, etc.
  * <p>
  * Internally, formats will be implemented using subclasses of {@link Format}
- * such as {@link DecimalFormat} and {@link SimpleDateFormat}. Therefore the
+ * such as {@link DecimalFormat} and {@link java.text.SimpleDateFormat}. Therefore the
  * formats used by this class must obey the same pattern rules as these Format
  * subclasses. This means that only legal number pattern characters ("0", "#",
  * ".", "," etc.) may appear in number formats. Other characters can be

Modified: poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/OOXMLSignatureFacet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/OOXMLSignatureFacet.java?rev=1701888&r1=1701887&r2=1701888&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/OOXMLSignatureFacet.java
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/OOXMLSignatureFacet.java
Wed Sep  9 00:41:03 2015
@@ -58,6 +58,7 @@ import org.apache.poi.openxml4j.opc.Pack
 import org.apache.poi.openxml4j.opc.TargetMode;
 import org.apache.poi.poifs.crypt.dsig.services.RelationshipTransformService;
 import org.apache.poi.poifs.crypt.dsig.services.RelationshipTransformService.RelationshipTransformParameterSpec;
+import org.apache.poi.util.LocaleUtil;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
 import org.openxmlformats.schemas.xpackage.x2006.digitalSignature.CTSignatureTime;
@@ -198,7 +199,7 @@ public class OOXMLSignatureFacet extends
          * SignatureTime
          */
         DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ROOT);
-        fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
+        fmt.setTimeZone(LocaleUtil.TIMEZONE_UTC);
         String nowStr = fmt.format(signatureConfig.getExecutionTime());
         LOG.log(POILogger.DEBUG, "now: " + nowStr);
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java?rev=1701888&r1=1701887&r2=1701888&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java Wed Sep  9
00:41:03 2015
@@ -45,6 +45,7 @@ import org.apache.poi.openxml4j.exceptio
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.DateUtil;
 import org.apache.poi.util.DocumentHelper;
+import org.apache.poi.util.LocaleUtil;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFMap;
 import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -316,6 +317,7 @@ public class XSSFExportToXml implements
 
     private String getFormattedDate(XSSFCell cell) {
         DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.ROOT);
+        sdf.setTimeZone(LocaleUtil.getUserTimeZone());
         return sdf.format(cell.getDateCellValue());
     }
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java?rev=1701888&r1=1701887&r2=1701888&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java Wed Sep  9 00:41:03
2015
@@ -523,6 +523,7 @@ public class SXSSFCell implements Cell {
      * <code>workbook.getCellStyleAt(0)</code>
      * @see org.apache.poi.ss.usermodel.Workbook#getCellStyleAt(short)
      */
+    @SuppressWarnings("resource")
     public CellStyle getCellStyle()
     {
         if(_style == null){
@@ -655,6 +656,7 @@ public class SXSSFCell implements Cell {
             case CELL_TYPE_NUMERIC:
                 if (DateUtil.isCellDateFormatted(this)) {
                     DateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", LocaleUtil.getUserLocale());
+                    sdf.setTimeZone(LocaleUtil.getUserTimeZone());
                     return sdf.format(getDateCellValue());
                 }
                 return getNumericCellValue() + "";

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java?rev=1701888&r1=1701887&r2=1701888&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java Wed Sep  9 00:41:03
2015
@@ -21,7 +21,6 @@ import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
-import java.util.Locale;
 
 import org.apache.poi.ss.SpreadsheetVersion;
 import org.apache.poi.ss.formula.FormulaParser;
@@ -42,6 +41,7 @@ import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellReference;
 import org.apache.poi.util.Internal;
+import org.apache.poi.util.LocaleUtil;
 import org.apache.poi.xssf.model.SharedStringsTable;
 import org.apache.poi.xssf.model.StylesTable;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
@@ -452,6 +452,7 @@ public final class XSSFCell implements C
         cellFormula.setRef(range.formatAsString());
     }
 
+    @SuppressWarnings("resource")
     private void setFormula(String formula, int formulaType) {
         XSSFWorkbook wb = _row.getSheet().getWorkbook();
         if (formula == null) {
@@ -841,7 +842,8 @@ public final class XSSFCell implements C
                 return getCellFormula();
             case CELL_TYPE_NUMERIC:
                 if (DateUtil.isCellDateFormatted(this)) {
-                    DateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", Locale.ROOT);
+                    DateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", LocaleUtil.getUserLocale());
+                    sdf.setTimeZone(LocaleUtil.getUserTimeZone());
                     return sdf.format(getDateCellValue());
                 }
                 return Double.toString(getNumericCellValue());

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/TestAttachments.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/TestAttachments.java?rev=1701888&r1=1701887&r2=1701888&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/TestAttachments.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/TestAttachments.java Wed Sep  9
00:41:03 2015
@@ -20,7 +20,8 @@ package org.apache.poi.hmef;
 import java.text.DateFormat;
 import java.util.List;
 import java.util.Locale;
-import java.util.TimeZone;
+
+import org.apache.poi.util.LocaleUtil;
 
 public final class TestAttachments extends HMEFTest {
    private HMEFMessage quick;
@@ -85,7 +86,7 @@ public final class TestAttachments exten
       DateFormat fmt = DateFormat.getDateTimeInstance(
             DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK
       );
-      fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
+      fmt.setTimeZone(LocaleUtil.TIMEZONE_UTC);
       
       // They should all have the same date on them
       assertEquals("28-Apr-2010 12:40:56", fmt.format( attachments.get(0).getModifiedDate()));

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java?rev=1701888&r1=1701887&r2=1701888&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java
(original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java
Wed Sep  9 00:41:03 2015
@@ -21,14 +21,14 @@ import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.text.DateFormat;
 import java.util.Locale;
-import java.util.TimeZone;
-
-import junit.framework.TestCase;
 
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.hmef.HMEFMessage;
 import org.apache.poi.hsmf.datatypes.MAPIProperty;
 import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.LocaleUtil;
+
+import junit.framework.TestCase;
 
 public final class TestMAPIAttributes extends TestCase {
    private static final POIDataSamples _samples = POIDataSamples.getHMEFInstance();
@@ -161,7 +161,7 @@ public final class TestMAPIAttributes ex
       DateFormat fmt = DateFormat.getDateTimeInstance(
             DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK
       );
-      fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
+      fmt.setTimeZone(LocaleUtil.TIMEZONE_UTC);
       assertEquals("15-Dec-2010 14:46:31", fmt.format(date.getDate()));
       
       // RTF

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestTNEFAttributes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestTNEFAttributes.java?rev=1701888&r1=1701887&r2=1701888&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestTNEFAttributes.java
(original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestTNEFAttributes.java
Wed Sep  9 00:41:03 2015
@@ -20,15 +20,15 @@ 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;
 
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.hmef.Attachment;
 import org.apache.poi.hmef.HMEFMessage;
 import org.apache.poi.hsmf.datatypes.MAPIProperty;
 import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.LocaleUtil;
+
+import junit.framework.TestCase;
 
 public final class TestTNEFAttributes extends TestCase {
    private static final POIDataSamples _samples = POIDataSamples.getHMEFInstance();
@@ -162,7 +162,7 @@ public final class TestTNEFAttributes ex
       DateFormat fmt = DateFormat.getDateTimeInstance(
             DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK
       );
-      fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
+      fmt.setTimeZone(LocaleUtil.TIMEZONE_UTC);
       assertEquals("28-Apr-2010 12:40:56", fmt.format(date.getDate()));
 	}
 	

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java?rev=1701888&r1=1701887&r2=1701888&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java Wed Sep
 9 00:41:03 2015
@@ -241,6 +241,7 @@ public final class TestHSSFDataFormatter
 			String monthPtrn = fmt.indexOf("mmmm") != -1 ? "MMMM" : "MMM";
 			// this line is intended to compute how "July" would look like in the current locale
 			SimpleDateFormat sdf = new SimpleDateFormat(monthPtrn, LocaleUtil.getUserLocale());
+			sdf.setTimeZone(LocaleUtil.getUserTimeZone());
 			Calendar calDef = LocaleUtil.getLocaleCalendar(2010, 6, 15, 0, 0, 0);
 			String jul = sdf.format(calDef.getTime());
 			// special case for MMMMM = 1st letter of month name



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message