我有两个具有不同时区的应用程序。
应用程序1: -Duser.timezone =澳大利亚/达尔文
应用程序2: -Duser.timeZone =亚洲/加尔各答
应用程序1插入基于Zone1的时间戳,应用程序2插入基于Zone2的时间戳。
从Application1中获取数据时,区域转换未完成。 而是显示相同的结果。
已将值插入数据库:
2019-02-19 15:39:40-Application1
2019-02-19 11:40:09-Application2
从应用程序1 /应用程序2提取时的输出
DB的时间戳记:2019-02-19 15:39:40.0
DB的时间戳记:2019-02-19 11:40:09.0
例如,如果从应用程序1中读取数据,则应根据Austria / Darwin显示时间戳。
如何实现?
这是代码段。
String selectSQL = "select createdtime from TZ_TEST6";
PreparedStatement ps = conn.prepareStatement(selectSQL);
ResultSet rs = ps.executeQuery(selectSQL );
while (rs.next())
{
Timestamp timestamp = rs.getTimestamp(1);
System.out.println("Time Stamp from DB: " +timestamp);
}