I have two applications with different time zones.
Application 1: -Duser.timezone=Australia/Darwin
Application 2: -Duser.timeZone=Asia/Kolkata
Application 1 inserts TimeStamp based on Zone1 and Application2 inserts TimeStamp based on Zone2.
While fetching data from Application1, Zone conversion is not done. Instead it displays the same result.
Values inserted to DB:
2019-02-19 15:39:40 - Application1
2019-02-19 11:40:09 - Application2
Output when fetched from Application 1/ Application2
Time Stamp from DB: 2019-02-19 15:39:40.0
Time Stamp from DB: 2019-02-19 11:40:09.0
For Example , if data is read from Application 1, time Stamp should be displayed according to Austria/Darwin.
How to achieve this?
Here is the code snippet.
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);
}