mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 10:04:21 +00:00
Ensure DSpace defaults to UTC time zone in all code / tests. This is necessary so that Spring / Hibernate don't auto-switch timezones when reading from database.
This commit is contained in:
@@ -12,6 +12,7 @@ import static org.junit.Assert.fail;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.sql.SQLException;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Properties;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@@ -82,8 +83,10 @@ public class AbstractDSpaceTest {
|
||||
@BeforeClass
|
||||
public static void initKernel() {
|
||||
try {
|
||||
//set a standard time zone for the tests
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("Europe/Dublin"));
|
||||
// All tests should assume UTC timezone by default (unless overridden in the test itself)
|
||||
// This ensures that Spring doesn't attempt to change the timezone of dates that are read from the
|
||||
// database (via Hibernate). We store all dates in the database as UTC.
|
||||
TimeZone.setDefault(TimeZone.getTimeZone(ZoneOffset.UTC));
|
||||
|
||||
//load the properties of the tests
|
||||
testProps = new Properties();
|
||||
|
Reference in New Issue
Block a user