title: Can I force Java to ignore timezones?
body: <p>Short version:
  Can I force Java to be timezone-ignorant?</p>
  
  <p>Longer version: 
  I have an older, Java 6-based, three-tier system with a Java GUI frontend (running on user PC's), a Java/OSGi middleware server and a Oracle 11g database backend. The two servers are located in the same rack within a cluster. The main entity (an inspection) stored in the database has a Date column which stores the date and time for the instant when the inspection occurred. The date and time are entered as strings in the GUI, and are stored in the DB as follows:</p>
  
  <pre><code>(theInspection.getInspectionDate() returns a java.util.Date object)
  
  inspectionDate = new java.sql.Timestamp(theInspection.getInspectionDate().getTime());
  ...
  statementHandler.openPreparedStatement(C_INSERT_INTO_INSPECTIONS);
  ...
  statementHandler.setTimestamp(4, inspectionDate);
  </code></pre>
  
  <p>The inspections date and time are then read back to the middleware server to identify and locate raw data files which have the date and time in their filenames. Reading from DB is done as follows:</p>
  
  <pre><code>resultSet.getDate("inspection_date");
  if (resultSet.wasNull()) {
      inspection.setInspectionDate(null);
      } else {
          date = new java.util.Date(resultSet.getDate("inspection_date").getTime() 
                      + resultSet.getTime("inspection_date").getTime() + (3600 * 1000L) );
          inspection.setInspectionDate(date);
      }
  </code></pre>
  
  <p>Now, this ran fine for years in CET/CEST (UTC+1) timezone, but moving it to MSK (UTC+3) broke it. The time gets shifted +2 hours when its stored to DB, and shifted again +2 hours when it is read back. I have established that it is Java that does this, Oracle is timezone-ignorant in this setup.</p>
  
  <p>I am considering changing this so that the middleware server converts to UTC when storing, and back to the local timezone when reading. I know that java.util.Date is deprecated and that there are other ways of representing time and date. However, I am concerned what would happen if the GUI client and the servers are in different timezones, or if servers or data are moved across timezones.</p>
  
  <p>Finally, it would perhaps make most sense to force Java to be timezone-ignorant. Is that at all possible?</p>
  
  <p>Thanks!</p>