import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
Integer key = Integer.valueOf(sid);
if (result.containsKey(key)) {
Class<?> prevClass = result.get(key).getRecordClass();
- throw new RuntimeException("duplicate record sid 0x" + Integer.toHexString(sid).toUpperCase()
- + " for classes (" + recClass.getName() + ") and (" + prevClass.getName() + ")");
+ throw new RuntimeException("duplicate record sid 0x" +
+ Integer.toHexString(sid).toUpperCase(Locale.ROOT)
+ + " for classes (" + recClass.getName() + ") and ("
+ + prevClass.getName() + ")");
}
result.put(key, getRecordCreator(recClass));
}
package org.apache.poi.hssf.usermodel;
+import java.util.Locale;
+
import org.apache.poi.hssf.record.PaletteRecord;
import org.apache.poi.hssf.util.HSSFColor;
{
int c = color & 0xff; //as unsigned
c = (c << 8) | c; //pad to 16-bit
- s = Integer.toHexString(c).toUpperCase();
+ s = Integer.toHexString(c).toUpperCase(Locale.ROOT);
while (s.length() < 4)
{
s = "0" + s;
import java.util.Calendar;
import java.util.GregorianCalendar;
+import java.util.Locale;
import java.util.TimeZone;
import org.apache.poi.ss.formula.eval.ErrorEval;
}
private static SimpleDate createDate(int dayCount) {
- GregorianCalendar calendar = new GregorianCalendar(UTC_TIME_ZONE);
+ GregorianCalendar calendar = new GregorianCalendar(UTC_TIME_ZONE, Locale.ROOT);
DateUtil.setCalendar(calendar, dayCount, 0, false, false);
return new SimpleDate(calendar);
}
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Locale;
+import java.util.TimeZone;
import org.apache.poi.ss.formula.eval.EvaluationException;
import org.apache.poi.ss.formula.eval.NumberEval;
* (twelve 30-day months), which is used in some accounting calculations. Use
* this function to help compute payments if your accounting system is based on
* twelve 30-day months.
- *
- * @author PUdalau
*/
public class Days360 extends Var2or3ArgFunction {
+ /**
+ * 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 ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1) {
double result;
}
private static Calendar getDate(double date) {
- Calendar processedDate = new GregorianCalendar(Locale.ROOT);
+ Calendar processedDate = new GregorianCalendar(DEFAULT_TIMEZONE, Locale.ROOT);
processedDate.setTime(DateUtil.getJavaDate(date, false));
return processedDate;
}
import java.util.Date;\r
import java.util.GregorianCalendar;\r
import java.util.Locale;\r
+import java.util.TimeZone;\r
\r
import org.apache.poi.ss.formula.OperationEvaluationContext;\r
import org.apache.poi.ss.formula.eval.ErrorEval;\r
* zero or negative (in the past).\r
*/\r
public class EOMonth implements FreeRefFunction {\r
-\r
+ /**\r
+ * Excel doesn't store TimeZone information in the file, so if in doubt,\r
+ * use UTC to perform calculations\r
+ */\r
+ private static final TimeZone DEFAULT_TIMEZONE = TimeZone.getTimeZone("UTC");\r
+ \r
public static final FreeRefFunction instance = new EOMonth();\r
\r
@Override\r
\r
Date startDate = DateUtil.getJavaDate(startDateAsNumber, false);\r
\r
- Calendar cal = new GregorianCalendar(Locale.ROOT);\r
+ Calendar cal = new GregorianCalendar(DEFAULT_TIMEZONE, Locale.ROOT);\r
cal.setTime(startDate);\r
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);\r
cal.set(Calendar.MILLISECOND, 0);\r
return e.getErrorEval();\r
}\r
}\r
-\r
}\r
*/
public static int convertColStringToIndex(String ref) {
int retval=0;
- char[] refs = ref.toUpperCase().toCharArray();
+ char[] refs = ref.toUpperCase(Locale.ROOT).toCharArray();
for (int k=0; k<refs.length; k++) {
char thechar = refs[k];
if (thechar == ABSOLUTE_REFERENCE_MARKER) {
return false; // that was easy
}
if(numberOfLetters == lastColLength) {
- if(colStr.toUpperCase().compareTo(lastCol) > 0) {
+ if(colStr.toUpperCase(Locale.ROOT).compareTo(lastCol) > 0) {
return false;
}
} else {
}
}
- col = reference.substring(start,loc).toUpperCase();
+ col = reference.substring(start,loc).toUpperCase(Locale.ROOT);
row = reference.substring(loc);
CellRefParts cellRefParts = new CellRefParts(sheetName, row, col);
return cellRefParts;