mirror of https://github.com/apache/poi.git
forbidden apis fixes - timezone fix ... will it work?
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1702321 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
91e804553b
commit
9f26731f44
|
@ -42,12 +42,27 @@ import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||||
import org.apache.poi.hssf.model.InternalWorkbook;
|
import org.apache.poi.hssf.model.InternalWorkbook;
|
||||||
import org.apache.poi.ss.usermodel.DateUtil;
|
import org.apache.poi.ss.usermodel.DateUtil;
|
||||||
import org.apache.poi.util.LocaleUtil;
|
import org.apache.poi.util.LocaleUtil;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TestHSSFDateUtil
|
* Class TestHSSFDateUtil
|
||||||
*/
|
*/
|
||||||
public final class TestHSSFDateUtil {
|
public class TestHSSFDateUtil {
|
||||||
|
|
||||||
|
static TimeZone userTimeZone;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setCEST() {
|
||||||
|
userTimeZone = LocaleUtil.getUserTimeZone();
|
||||||
|
LocaleUtil.setUserTimeZone(TimeZone.getTimeZone("CEST"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void resetTimeZone() {
|
||||||
|
LocaleUtil.setUserTimeZone(userTimeZone);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the date conversion functions in the HSSFDateUtil class.
|
* Checks the date conversion functions in the HSSFDateUtil class.
|
||||||
|
@ -136,9 +151,9 @@ public final class TestHSSFDateUtil {
|
||||||
|
|
||||||
cal.set(Calendar.HOUR_OF_DAY, hour);
|
cal.set(Calendar.HOUR_OF_DAY, hour);
|
||||||
Date javaDate = HSSFDateUtil.getJavaDate(excelDate, false);
|
Date javaDate = HSSFDateUtil.getJavaDate(excelDate, false);
|
||||||
|
double actDate = HSSFDateUtil.getExcelDate(javaDate, false);
|
||||||
assertEquals("Checking " + hour + " hours on Daylight Saving Time start date",
|
assertEquals("Checking " + hour + " hours on Daylight Saving Time start date",
|
||||||
excelDate,
|
excelDate, actDate, oneMinute);
|
||||||
HSSFDateUtil.getExcelDate(javaDate, false), oneMinute);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,7 @@ public final class TestText {
|
||||||
// update: now the locale will be (if not set otherwise) always Locale.getDefault() (see LocaleUtil)
|
// update: now the locale will be (if not set otherwise) always Locale.getDefault() (see LocaleUtil)
|
||||||
DateFormatSymbols dfs = DateFormatSymbols.getInstance(LocaleUtil.getUserLocale());
|
DateFormatSymbols dfs = DateFormatSymbols.getInstance(LocaleUtil.getUserLocale());
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("MMMM", dfs);
|
SimpleDateFormat sdf = new SimpleDateFormat("MMMM", dfs);
|
||||||
|
sdf.setTimeZone(LocaleUtil.getUserTimeZone());
|
||||||
String november = sdf.format(LocaleUtil.getLocaleCalendar(2015,10,1).getTime());
|
String november = sdf.format(LocaleUtil.getLocaleCalendar(2015,10,1).getTime());
|
||||||
|
|
||||||
// Again with Java style
|
// Again with Java style
|
||||||
|
|
Loading…
Reference in New Issue