mirror of https://github.com/apache/poi.git
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
928c6140ba
commit
a49d4bdd07
|
@ -24,14 +24,19 @@ import java.util.Calendar;
|
|||
import java.util.Date;
|
||||
import java.util.Formatter;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
/**
|
||||
* Formats a date value.
|
||||
*
|
||||
* @author Ken Arnold, Industrious Media LLC
|
||||
*/
|
||||
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 showM;
|
||||
private boolean showAmPm;
|
||||
|
@ -45,7 +50,7 @@ public class CellDateFormatter extends CellFormatter {
|
|||
"mm/d/y");
|
||||
|
||||
static {
|
||||
Calendar c = Calendar.getInstance();
|
||||
Calendar c = Calendar.getInstance(DEFAULT_TIMEZONE, Locale.ROOT);
|
||||
c.set(1904, 0, 1, 0, 0, 0);
|
||||
EXCEL_EPOCH_DATE = c.getTime();
|
||||
EXCEL_EPOCH_TIME = c.getTimeInMillis();
|
||||
|
@ -183,7 +188,7 @@ public class CellDateFormatter extends CellFormatter {
|
|||
if (!doneMillis) {
|
||||
Date dateObj = (Date) value;
|
||||
int pos = toAppendTo.length();
|
||||
Formatter formatter = new Formatter(toAppendTo);
|
||||
Formatter formatter = new Formatter(toAppendTo, Locale.ROOT);
|
||||
try {
|
||||
long msecs = dateObj.getTime() % 1000;
|
||||
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.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 1 Week begins on Sunday. 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 {
|
||||
/**
|
||||
* 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();
|
||||
|
||||
|
@ -53,7 +57,7 @@ public class WeekNum extends Fixed2ArgFunction implements FreeRefFunction {
|
|||
} catch (EvaluationException e) {
|
||||
return ErrorEval.VALUE_INVALID;
|
||||
}
|
||||
Calendar serialNumCalendar = new GregorianCalendar(Locale.ROOT);
|
||||
Calendar serialNumCalendar = new GregorianCalendar(DEFAULT_TIMEZONE, Locale.ROOT);
|
||||
serialNumCalendar.setTime(DateUtil.getJavaDate(serialNum, false));
|
||||
|
||||
int returnType = 0;
|
||||
|
|
|
@ -24,9 +24,6 @@ import java.util.ArrayList;
|
|||
/**
|
||||
* Utilities to read hex from files.
|
||||
* TODO - move to test packages
|
||||
*
|
||||
* @author Marc Johnson
|
||||
* @author Glen Stampoultzis (glens at apache.org)
|
||||
*/
|
||||
public class HexRead
|
||||
{
|
||||
|
@ -174,7 +171,7 @@ public class HexRead
|
|||
|
||||
static public byte[] readFromString(String data) {
|
||||
try {
|
||||
return readData(new ByteArrayInputStream( data.getBytes() ), -1);
|
||||
return readData(new ByteArrayInputStream( data.getBytes(StringUtil.UTF8) ), -1);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue