import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.util.LocaleUtil;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
/**
* 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.
*/
cal.set(Calendar.HOUR_OF_DAY, hour);
Date javaDate = HSSFDateUtil.getJavaDate(excelDate, false);
+ double actDate = HSSFDateUtil.getExcelDate(javaDate, false);
assertEquals("Checking " + hour + " hours on Daylight Saving Time start date",
- excelDate,
- HSSFDateUtil.getExcelDate(javaDate, false), oneMinute);
+ excelDate, actDate, oneMinute);
}
}
// update: now the locale will be (if not set otherwise) always Locale.getDefault() (see LocaleUtil)
DateFormatSymbols dfs = DateFormatSymbols.getInstance(LocaleUtil.getUserLocale());
SimpleDateFormat sdf = new SimpleDateFormat("MMMM", dfs);
+ sdf.setTimeZone(LocaleUtil.getUserTimeZone());
String november = sdf.format(LocaleUtil.getLocaleCalendar(2015,10,1).getTime());
// Again with Java style