You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2015/09/01 21:36:22 UTC

svn commit: r1700652 - in /poi/trunk/src/java/org/apache/poi: hpsf/Property.java hssf/usermodel/DVConstraint.java ss/formula/atp/DateParser.java

Author: nick
Date: Tue Sep  1 19:36:22 2015
New Revision: 1700652

URL: http://svn.apache.org/r1700652
Log:
Fix some Forbidden APIs errors

Modified:
    poi/trunk/src/java/org/apache/poi/hpsf/Property.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/DVConstraint.java
    poi/trunk/src/java/org/apache/poi/ss/formula/atp/DateParser.java

Modified: poi/trunk/src/java/org/apache/poi/hpsf/Property.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hpsf/Property.java?rev=1700652&r1=1700651&r2=1700652&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hpsf/Property.java (original)
+++ poi/trunk/src/java/org/apache/poi/hpsf/Property.java Tue Sep  1 19:36:22 2015
@@ -18,6 +18,7 @@
 package org.apache.poi.hpsf;
 
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -52,9 +53,6 @@ import org.apache.poi.util.POILogger;
  * href="http://msdn.microsoft.com/library/en-us/stg/stg/property_set_display_name_dictionary.asp?frame=true">
  * Property Set Display Name Dictionary</a>.
  *
- * @author Rainer Klute <a
- * href="mailto:klute@rainer-klute.de">&lt;klute@rainer-klute.de&gt;</a>
- * @author Drew Varner (Drew.Varner InAndAround sc.edu)
  * @see Section
  * @see Variant
  */
@@ -238,7 +236,7 @@ public class Property
                     {
                         /* Without a codepage the length is equal to the number of
                          * bytes. */
-                        b.append(new String(src, o, (int) sLength));
+                        b.append(new String(src, o, (int) sLength, Charset.forName("ASCII")));
                         break;
                     }
                     case CodePageUtil.CP_UNICODE:

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=1700652&r1=1700651&r2=1700652&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 Tue Sep  1 19:36:22 2015
@@ -21,6 +21,7 @@ import java.text.MessageFormat;
 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;
@@ -55,10 +56,6 @@ public class DVConstraint implements Dat
 		
 	}
 	
-	// convenient access to ValidationType namespace
-	private static final ValidationType VT = null;
-
-	
 	private final int _validationType;
 	private int _operator;
 	private String[] _explicitListValues;
@@ -184,7 +181,7 @@ public class DVConstraint implements Dat
 			throw new IllegalArgumentException("expr1 must be supplied");
 		}
 		OperatorType.validateSecondArg(comparisonOperator, expr2);
-		SimpleDateFormat df = dateFormat == null ? null : new SimpleDateFormat(dateFormat);
+		SimpleDateFormat df = dateFormat == null ? null : new SimpleDateFormat(dateFormat, Locale.ROOT);
 		
 		// formula1 and value1 are mutually exclusive
 		String formula1 = getFormulaFromTextExpression(expr1);

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/atp/DateParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/atp/DateParser.java?rev=1700652&r1=1700651&r2=1700652&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/atp/DateParser.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/atp/DateParser.java Tue Sep  1 19:36:22 2015
@@ -19,6 +19,8 @@ package org.apache.poi.ss.formula.atp;
 
 import java.util.Calendar;
 import java.util.GregorianCalendar;
+import java.util.Locale;
+import java.util.TimeZone;
 import java.util.regex.Pattern;
 
 import org.apache.poi.ss.formula.eval.ErrorEval;
@@ -26,10 +28,13 @@ import org.apache.poi.ss.formula.eval.Ev
 
 /**
  * Parser for java dates.
- * 
- * @author jfaenomoto@gmail.com
  */
 public class DateParser {
+    /**
+     * Excel doesn't store TimeZone information in the file, so if in doubt,
+     *  use UTC to perform calculations
+     */
+    private static final TimeZone DEFAULT_TIMEZONE = TimeZone.getTimeZone("UTC");
 
     public DateParser instance = new DateParser();
 
@@ -90,7 +95,8 @@ public class DateParser {
         if (month < 1 || month > 12) {
             throw new EvaluationException(ErrorEval.VALUE_INVALID);
         }
-        Calendar cal = new GregorianCalendar(year, month - 1, 1, 0, 0, 0);
+        Calendar cal = new GregorianCalendar(DEFAULT_TIMEZONE, Locale.ROOT);
+        cal.set(year, month - 1, 1, 0, 0, 0);
         cal.set(Calendar.MILLISECOND, 0);
         if (day < 1 || day > cal.getActualMaximum(Calendar.DAY_OF_MONTH)) {
             throw new EvaluationException(ErrorEval.VALUE_INVALID);



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