mirror of https://github.com/apache/poi.git
Fix some Forbidden APIs errors
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1700635 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
72433ac405
commit
4ee2705d7a
|
@ -19,6 +19,7 @@ package org.apache.poi.ss.formula.functions;
|
|||
|
||||
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;
|
||||
|
@ -86,7 +87,7 @@ public final class DateFunc extends Fixed3ArgFunction {
|
|||
}
|
||||
|
||||
// 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);
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.poi.ss.formula.functions;
|
|||
|
||||
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;
|
||||
|
@ -72,7 +73,7 @@ public class Days360 extends Var2or3ArgFunction {
|
|||
}
|
||||
|
||||
private static Calendar getDate(double date) {
|
||||
Calendar processedDate = new GregorianCalendar();
|
||||
Calendar processedDate = new GregorianCalendar(Locale.ROOT);
|
||||
processedDate.setTime(DateUtil.getJavaDate(date, false));
|
||||
return processedDate;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.poi.ss.formula.functions;
|
|||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.poi.ss.formula.OperationEvaluationContext;
|
||||
import org.apache.poi.ss.formula.eval.ErrorEval;
|
||||
|
@ -63,7 +64,7 @@ public class EOMonth implements FreeRefFunction {
|
|||
|
||||
Date startDate = DateUtil.getJavaDate(startDateAsNumber, false);
|
||||
|
||||
Calendar cal = new GregorianCalendar();
|
||||
Calendar cal = new GregorianCalendar(Locale.ROOT);
|
||||
cal.setTime(startDate);
|
||||
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.poi.ss.formula.functions;
|
|||
|
||||
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;
|
||||
|
@ -33,7 +34,7 @@ public final class Today extends Fixed0ArgFunction {
|
|||
|
||||
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()));
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.poi.ss.usermodel.DateUtil;
|
|||
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Implementation for Excel WeekNum() function.<p/>
|
||||
|
@ -52,7 +53,7 @@ public class WeekNum extends Fixed2ArgFunction implements FreeRefFunction {
|
|||
} catch (EvaluationException e) {
|
||||
return ErrorEval.VALUE_INVALID;
|
||||
}
|
||||
Calendar serialNumCalendar = new GregorianCalendar();
|
||||
Calendar serialNumCalendar = new GregorianCalendar(Locale.ROOT);
|
||||
serialNumCalendar.setTime(DateUtil.getJavaDate(serialNum, false));
|
||||
|
||||
int returnType = 0;
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.poi.ss.usermodel;
|
|||
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;
|
||||
|
||||
|
@ -83,7 +84,7 @@ public class DateUtil {
|
|||
* @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);
|
||||
}
|
||||
|
@ -319,9 +320,9 @@ public class DateUtil {
|
|||
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;
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.nio.charset.Charset;
|
|||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
@ -142,14 +143,14 @@ public final class TestUnfixedBugs extends TestCase {
|
|||
// second to be different here!
|
||||
int startYear = 1900;
|
||||
int dayAdjust = -1; // Excel thinks 2/29/1900 is a valid date, which it isn't
|
||||
Calendar calendar1 = new GregorianCalendar();
|
||||
Calendar calendar1 = new GregorianCalendar(Locale.ROOT);
|
||||
calendar1.set(startYear,0, wholeDays1 + dayAdjust, 0, 0, 0);
|
||||
calendar1.set(Calendar.MILLISECOND, millisecondsInDay1);
|
||||
// this is the rounding part:
|
||||
calendar1.add(Calendar.MILLISECOND, 500);
|
||||
calendar1.clear(Calendar.MILLISECOND);
|
||||
|
||||
Calendar calendar2 = new GregorianCalendar();
|
||||
Calendar calendar2 = new GregorianCalendar(Locale.ROOT);
|
||||
calendar2.set(startYear,0, wholeDays2 + dayAdjust, 0, 0, 0);
|
||||
calendar2.set(Calendar.MILLISECOND, millisecondsInDay2);
|
||||
// this is the rounding part:
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.poi.hslf.util;
|
|||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
|
@ -47,7 +48,7 @@ public final class SystemTimeUtils {
|
|||
* 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);
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Calendar;
|
|||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
@ -227,7 +228,7 @@ public class TestWriteWellKnown extends 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);
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.text.SimpleDateFormat;
|
|||
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;
|
||||
|
@ -461,7 +462,7 @@ public final class TestHSSFDateUtil {
|
|||
* @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();
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.poi.ss.formula.atp;
|
|||
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
@ -58,7 +59,7 @@ public final class TestYearFracCalculator extends 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);
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.poi.ss.formula.functions;
|
|||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
import junit.framework.TestCase;
|
||||
|
@ -44,13 +45,13 @@ public final class TestDays360 extends 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));
|
||||
|
|
Loading…
Reference in New Issue