Fix locale error

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1711726 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2015-11-01 08:43:57 +00:00
parent 5fd534c44b
commit cff4102574
1 changed files with 11 additions and 9 deletions

View File

@ -32,6 +32,7 @@ import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.zip.CRC32; import java.util.zip.CRC32;
@ -63,6 +64,7 @@ import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.ss.util.AreaReference; import org.apache.poi.ss.util.AreaReference;
import org.apache.poi.ss.util.CellReference; import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LocaleUtil;
import org.apache.poi.util.TempFile; import org.apache.poi.util.TempFile;
import org.apache.poi.xssf.XSSFITestDataProvider; import org.apache.poi.xssf.XSSFITestDataProvider;
import org.apache.poi.xssf.XSSFTestDataSamples; import org.apache.poi.xssf.XSSFTestDataSamples;
@ -1039,7 +1041,7 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
@Test @Test
public void testBug56957CloseWorkbook() throws Exception { public void testBug56957CloseWorkbook() throws Exception {
File file = TempFile.createTempFile("TestBug56957_", ".xlsx"); File file = TempFile.createTempFile("TestBug56957_", ".xlsx");
final String dateExp = "Sun Nov 09 00:00:00 CET 2014"; final Date dateExp = LocaleUtil.getLocaleCalendar(2014, 10, 9).getTime();
try { try {
// as the file is written to, we make a copy before actually working on it // as the file is written to, we make a copy before actually working on it
@ -1049,27 +1051,27 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
// read-only mode works! // read-only mode works!
Workbook workbook = WorkbookFactory.create(OPCPackage.open(file, PackageAccess.READ)); Workbook workbook = WorkbookFactory.create(OPCPackage.open(file, PackageAccess.READ));
String str = workbook.getSheetAt(0).getRow(0).getCell(0, Row.CREATE_NULL_AS_BLANK).getDateCellValue().toString(); Date dateAct = workbook.getSheetAt(0).getRow(0).getCell(0, Row.CREATE_NULL_AS_BLANK).getDateCellValue();
assertEquals(dateExp, str); assertEquals(dateExp, dateAct);
workbook.close(); workbook.close();
workbook = null; workbook = null;
workbook = WorkbookFactory.create(OPCPackage.open(file, PackageAccess.READ)); workbook = WorkbookFactory.create(OPCPackage.open(file, PackageAccess.READ));
str = workbook.getSheetAt(0).getRow(0).getCell(0, Row.CREATE_NULL_AS_BLANK).getDateCellValue().toString(); dateAct = workbook.getSheetAt(0).getRow(0).getCell(0, Row.CREATE_NULL_AS_BLANK).getDateCellValue();
assertEquals(dateExp, str); assertEquals(dateExp, dateAct);
workbook.close(); workbook.close();
workbook = null; workbook = null;
// now check read/write mode // now check read/write mode
workbook = WorkbookFactory.create(OPCPackage.open(file, PackageAccess.READ_WRITE)); workbook = WorkbookFactory.create(OPCPackage.open(file, PackageAccess.READ_WRITE));
str = workbook.getSheetAt(0).getRow(0).getCell(0, Row.CREATE_NULL_AS_BLANK).getDateCellValue().toString(); dateAct = workbook.getSheetAt(0).getRow(0).getCell(0, Row.CREATE_NULL_AS_BLANK).getDateCellValue();
assertEquals(dateExp, str); assertEquals(dateExp, dateAct);
workbook.close(); workbook.close();
workbook = null; workbook = null;
workbook = WorkbookFactory.create(OPCPackage.open(file, PackageAccess.READ_WRITE)); workbook = WorkbookFactory.create(OPCPackage.open(file, PackageAccess.READ_WRITE));
str = workbook.getSheetAt(0).getRow(0).getCell(0, Row.CREATE_NULL_AS_BLANK).getDateCellValue().toString(); dateAct = workbook.getSheetAt(0).getRow(0).getCell(0, Row.CREATE_NULL_AS_BLANK).getDateCellValue();
assertEquals(dateExp, str); assertEquals(dateExp, dateAct);
workbook.close(); workbook.close();
workbook = null; workbook = null;
} finally { } finally {