import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.time.ZoneId;
+import java.time.ZoneOffset;
import java.util.Calendar;
import java.util.Date;
import java.util.Optional;
try (OPCPackage pkg = OPCPackage.open(_ssTests.openResourceAsStream("sample.strict.xlsx"))) {
POIXMLProperties props = new POIXMLProperties(pkg);
assertNotNull(props.getCoreProperties().getCreated());
- assertEquals(2007, props.getCoreProperties().getCreated().toInstant().atZone(ZoneId.of("UTC")).getYear());
+ assertEquals(2007, props.getCoreProperties().getCreated().toInstant().atZone(ZoneOffset.UTC).getYear());
}
}
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
+import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.temporal.ChronoField;
*/
public static LocalDateTime toLocalDateTime(Date date) {
return date.toInstant()
- .atZone(TimeZone.getTimeZone("UTC").toZoneId()) // java.util.Date uses UTC
+ .atZone(TimeZone.getTimeZone(ZoneOffset.UTC).toZoneId()) // java.util.Date uses UTC
.toLocalDateTime();
}
*/
public static LocalDateTime toLocalDateTime(Calendar date) {
return date.toInstant()
- .atZone(TimeZone.getTimeZone("UTC").toZoneId()) // java.util.Date uses UTC
+ .atZone(TimeZone.getTimeZone(ZoneOffset.UTC).toZoneId()) // java.util.Date uses UTC
.toLocalDateTime();
}
package org.apache.poi.util;
import java.nio.charset.Charset;
+import java.time.ZoneOffset;
import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;
* Excel doesn't store TimeZone information in the file, so if in doubt,
* use UTC to perform calculations
*/
- public static final TimeZone TIMEZONE_UTC = TimeZone.getTimeZone("UTC");
+ public static final TimeZone TIMEZONE_UTC = TimeZone.getTimeZone(ZoneOffset.UTC);
/**
* Default encoding for unknown byte encodings of native files
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.LocalDateTime;
+import java.time.ZoneOffset;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
cell.setCellValue(new Date());
assertEquals(CellType.FORMULA, cell.getCellType());
- cell.setCellValue(GregorianCalendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ROOT));
+ cell.setCellValue(GregorianCalendar.getInstance(TimeZone.getTimeZone(ZoneOffset.UTC), Locale.ROOT));
assertEquals(CellType.FORMULA, cell.getCellType());
cell.setCellValue(1.0);