Fix some Forbidden APIs errors
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1700675 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
83399ac543
commit
d00fb8a65b
@ -24,14 +24,19 @@ import java.util.Calendar;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Formatter;
|
import java.util.Formatter;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.TimeZone;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats a date value.
|
* Formats a date value.
|
||||||
*
|
|
||||||
* @author Ken Arnold, Industrious Media LLC
|
|
||||||
*/
|
*/
|
||||||
public class CellDateFormatter extends CellFormatter {
|
public class CellDateFormatter extends CellFormatter {
|
||||||
|
/**
|
||||||
|
* 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");
|
||||||
|
|
||||||
private boolean amPmUpper;
|
private boolean amPmUpper;
|
||||||
private boolean showM;
|
private boolean showM;
|
||||||
private boolean showAmPm;
|
private boolean showAmPm;
|
||||||
@ -45,7 +50,7 @@ public class CellDateFormatter extends CellFormatter {
|
|||||||
"mm/d/y");
|
"mm/d/y");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Calendar c = Calendar.getInstance();
|
Calendar c = Calendar.getInstance(DEFAULT_TIMEZONE, Locale.ROOT);
|
||||||
c.set(1904, 0, 1, 0, 0, 0);
|
c.set(1904, 0, 1, 0, 0, 0);
|
||||||
EXCEL_EPOCH_DATE = c.getTime();
|
EXCEL_EPOCH_DATE = c.getTime();
|
||||||
EXCEL_EPOCH_TIME = c.getTimeInMillis();
|
EXCEL_EPOCH_TIME = c.getTimeInMillis();
|
||||||
@ -183,7 +188,7 @@ public class CellDateFormatter extends CellFormatter {
|
|||||||
if (!doneMillis) {
|
if (!doneMillis) {
|
||||||
Date dateObj = (Date) value;
|
Date dateObj = (Date) value;
|
||||||
int pos = toAppendTo.length();
|
int pos = toAppendTo.length();
|
||||||
Formatter formatter = new Formatter(toAppendTo);
|
Formatter formatter = new Formatter(toAppendTo, Locale.ROOT);
|
||||||
try {
|
try {
|
||||||
long msecs = dateObj.getTime() % 1000;
|
long msecs = dateObj.getTime() % 1000;
|
||||||
formatter.format(LOCALE, sFmt, msecs / 1000.0);
|
formatter.format(LOCALE, sFmt, msecs / 1000.0);
|
||||||
|
@ -24,6 +24,7 @@ import org.apache.poi.ss.usermodel.DateUtil;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation for Excel WeekNum() function.<p/>
|
* Implementation for Excel WeekNum() function.<p/>
|
||||||
@ -39,10 +40,13 @@ import java.util.Locale;
|
|||||||
* Return_type is a number that determines on which day the week begins. The default is 1.
|
* Return_type is a number that determines on which day the week begins. The default is 1.
|
||||||
* 1 Week begins on Sunday. Weekdays are numbered 1 through 7.
|
* 1 Week begins on Sunday. Weekdays are numbered 1 through 7.
|
||||||
* 2 Week begins on Monday. Weekdays are numbered 1 through 7.
|
* 2 Week begins on Monday. Weekdays are numbered 1 through 7.
|
||||||
*
|
|
||||||
* @author cedric dot walter @ gmail dot com
|
|
||||||
*/
|
*/
|
||||||
public class WeekNum extends Fixed2ArgFunction implements FreeRefFunction {
|
public class WeekNum extends Fixed2ArgFunction implements FreeRefFunction {
|
||||||
|
/**
|
||||||
|
* 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 static final FreeRefFunction instance = new WeekNum();
|
public static final FreeRefFunction instance = new WeekNum();
|
||||||
|
|
||||||
@ -53,7 +57,7 @@ public class WeekNum extends Fixed2ArgFunction implements FreeRefFunction {
|
|||||||
} catch (EvaluationException e) {
|
} catch (EvaluationException e) {
|
||||||
return ErrorEval.VALUE_INVALID;
|
return ErrorEval.VALUE_INVALID;
|
||||||
}
|
}
|
||||||
Calendar serialNumCalendar = new GregorianCalendar(Locale.ROOT);
|
Calendar serialNumCalendar = new GregorianCalendar(DEFAULT_TIMEZONE, Locale.ROOT);
|
||||||
serialNumCalendar.setTime(DateUtil.getJavaDate(serialNum, false));
|
serialNumCalendar.setTime(DateUtil.getJavaDate(serialNum, false));
|
||||||
|
|
||||||
int returnType = 0;
|
int returnType = 0;
|
||||||
|
@ -24,9 +24,6 @@ import java.util.ArrayList;
|
|||||||
/**
|
/**
|
||||||
* Utilities to read hex from files.
|
* Utilities to read hex from files.
|
||||||
* TODO - move to test packages
|
* TODO - move to test packages
|
||||||
*
|
|
||||||
* @author Marc Johnson
|
|
||||||
* @author Glen Stampoultzis (glens at apache.org)
|
|
||||||
*/
|
*/
|
||||||
public class HexRead
|
public class HexRead
|
||||||
{
|
{
|
||||||
@ -174,7 +171,7 @@ public class HexRead
|
|||||||
|
|
||||||
static public byte[] readFromString(String data) {
|
static public byte[] readFromString(String data) {
|
||||||
try {
|
try {
|
||||||
return readData(new ByteArrayInputStream( data.getBytes() ), -1);
|
return readData(new ByteArrayInputStream( data.getBytes(StringUtil.UTF8) ), -1);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user