This project that I have is using a MySQL database. But now, I want to move to PostgreSQL. Everything works fine except for one table that has a column of type timestamp.
//MedName is varchar, and DateTime is timestamp
String INSERT_REFILL = "INSERT INTO refill (MedName, DateTime) VALUES (?, ?)";
PreparedStatement ps = conn.prepareStatement(INSERT_REFILL);
ps.setString(1, "Tylenol");
java.sql.Timestamp sqlDate = new java.sql.Timestamp(new java.util.Date().getTime());
TimeZone tz = TimeZone.getTimeZone("GMT");
GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance(tz);
ps.setTimestamp(2, sqlDate, cal);
My Question: For some reason, the setTimestamp always adds 5 hours to the values of the PreparedStatement. I'm in Central, so my time will be xx:xx:xx-0500 (Central) due to daylight savings. But I really doubt the +5 hours comes from that. Any ideas?
Note: I'm not the one who set up the PostgreSQL database but I created the table.