import java.util.Calendar;
import java.util.GregorianCalendar;
+import java.util.Locale;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.EvaluationException;
}
// Turn this into a Java date
- Calendar c = new GregorianCalendar();
+ Calendar c = new GregorianCalendar(Locale.ROOT);
c.set(year, month, day, 0, 0, 0);
c.set(Calendar.MILLISECOND, 0);
import java.util.Calendar;
import java.util.GregorianCalendar;
+import java.util.Locale;
import org.apache.poi.ss.formula.eval.EvaluationException;
import org.apache.poi.ss.formula.eval.NumberEval;
}
private static Calendar getDate(double date) {
- Calendar processedDate = new GregorianCalendar();
+ Calendar processedDate = new GregorianCalendar(Locale.ROOT);
processedDate.setTime(DateUtil.getJavaDate(date, false));
return processedDate;
}
import java.util.Calendar;\r
import java.util.Date;\r
import java.util.GregorianCalendar;\r
+import java.util.Locale;\r
\r
import org.apache.poi.ss.formula.OperationEvaluationContext;\r
import org.apache.poi.ss.formula.eval.ErrorEval;\r
\r
Date startDate = DateUtil.getJavaDate(startDateAsNumber, false);\r
\r
- Calendar cal = new GregorianCalendar();\r
+ Calendar cal = new GregorianCalendar(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
import java.util.Calendar;
import java.util.GregorianCalendar;
+import java.util.Locale;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.ValueEval;
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex) {
- Calendar now = new GregorianCalendar();
+ Calendar now = new GregorianCalendar(Locale.ROOT);
now.set(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DATE),0,0,0);
now.set(Calendar.MILLISECOND, 0);
return new NumberEval(DateUtil.getExcelDate(now.getTime()));
\r
import java.util.Calendar;\r
import java.util.GregorianCalendar;\r
+import java.util.Locale;\r
\r
/**\r
* Implementation for Excel WeekNum() function.<p/>\r
} catch (EvaluationException e) {\r
return ErrorEval.VALUE_INVALID;\r
}\r
- Calendar serialNumCalendar = new GregorianCalendar();\r
+ Calendar serialNumCalendar = new GregorianCalendar(Locale.ROOT);\r
serialNumCalendar.setTime(DateUtil.getJavaDate(serialNum, false));\r
\r
int returnType = 0;\r
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
+import java.util.Locale;
import java.util.TimeZone;
import java.util.regex.Pattern;
* @param use1904windowing Should 1900 or 1904 date windowing be used?
*/
public static double getExcelDate(Date date, boolean use1904windowing) {
- Calendar calStart = new GregorianCalendar();
+ Calendar calStart = new GregorianCalendar(Locale.ROOT);
calStart.setTime(date); // If date includes hours, minutes, and seconds, set them to 0
return internalGetExcelDate(calStart, use1904windowing);
}
int millisecondsInDay = (int)((date - wholeDays) * DAY_MILLISECONDS + 0.5);
Calendar calendar;
if (timeZone != null) {
- calendar = new GregorianCalendar(timeZone);
+ calendar = new GregorianCalendar(timeZone, Locale.ROOT);
} else {
- calendar = new GregorianCalendar(); // using default time-zone
+ calendar = new GregorianCalendar(Locale.ROOT); // using default time-zone
}
setCalendar(calendar, wholeDays, millisecondsInDay, use1904windowing, roundSeconds);
return calendar;
import java.util.Calendar;\r
import java.util.Date;\r
import java.util.GregorianCalendar;\r
+import java.util.Locale;\r
\r
import junit.framework.TestCase;\r
\r
// second to be different here!\r
int startYear = 1900;\r
int dayAdjust = -1; // Excel thinks 2/29/1900 is a valid date, which it isn't\r
- Calendar calendar1 = new GregorianCalendar();\r
+ Calendar calendar1 = new GregorianCalendar(Locale.ROOT);\r
calendar1.set(startYear,0, wholeDays1 + dayAdjust, 0, 0, 0);\r
calendar1.set(Calendar.MILLISECOND, millisecondsInDay1);\r
// this is the rounding part:\r
calendar1.add(Calendar.MILLISECOND, 500);\r
calendar1.clear(Calendar.MILLISECOND);\r
\r
- Calendar calendar2 = new GregorianCalendar();\r
+ Calendar calendar2 = new GregorianCalendar(Locale.ROOT);\r
calendar2.set(startYear,0, wholeDays2 + dayAdjust, 0, 0, 0);\r
calendar2.set(Calendar.MILLISECOND, millisecondsInDay2);\r
// this is the rounding part:\r
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
+import java.util.Locale;
import org.apache.poi.util.LittleEndian;
* Get the date found in the byte array, as a java Data object
*/
public static Date getDate(byte[] data, int offset) {
- Calendar cal = new GregorianCalendar();
+ Calendar cal = new GregorianCalendar(Locale.ROOT);
cal.set(Calendar.YEAR, LittleEndian.getShort(data,offset));
cal.set(Calendar.MONTH, LittleEndian.getShort(data,offset+2)-1);
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
import junit.framework.TestCase;
* (e.g. author, edit date, application name) and to the document
* summary information (e.g. company, manager).
*/
- Calendar cal = new GregorianCalendar();
+ Calendar cal = new GregorianCalendar(Locale.ROOT);
cal.set(2000, 6, 6, 6, 6, 6);
final long time1 = cal.getTimeInMillis();
cal.set(2001, 7, 7, 7, 7, 7);
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
+import java.util.Locale;
import java.util.TimeZone;
import org.apache.poi.hssf.HSSFTestDataSamples;
* @param day one based
*/
private static Date createDate(int year, int month, int day, int hour, int minute, int second) {
- Calendar c = new GregorianCalendar();
+ Calendar c = new GregorianCalendar(Locale.ROOT);
c.set(year, month, day, hour, minute, second);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
import java.util.Calendar;
import java.util.GregorianCalendar;
+import java.util.Locale;
import junit.framework.TestCase;
}
private static double md(int year, int month, int day) {
- Calendar c = new GregorianCalendar();
+ Calendar c = new GregorianCalendar(Locale.ROOT);
c.set(year, month-1, day, 0, 0, 0);
c.set(Calendar.MILLISECOND, 0);
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
+import java.util.Locale;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
return cal.getTime();
}
private static Date decrementDay(Date d) {
- Calendar c = new GregorianCalendar();
+ Calendar c = new GregorianCalendar(Locale.ROOT);
c.setTimeInMillis(d.getTime());
c.add(Calendar.DAY_OF_MONTH, -1);
return c.getTime();
}
private static String fmt(Date d) {
- Calendar c = new GregorianCalendar();
+ Calendar c = new GregorianCalendar(Locale.ROOT);
c.setTimeInMillis(d.getTime());
StringBuilder sb = new StringBuilder();
sb.append(c.get(Calendar.YEAR));