package org.apache.poi.hpsf;
import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
import java.util.LinkedHashMap;
import java.util.Map;
* 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"><klute@rainer-klute.de></a>
- * @author Drew Varner (Drew.Varner InAndAround sc.edu)
* @see Section
* @see Variant
*/
{
/* 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:
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;
}
- // convenient access to ValidationType namespace
- private static final ValidationType VT = null;
-
-
private final int _validationType;
private int _operator;
private String[] _explicitListValues;
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);
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;
/**
* 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();
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);