0

I need to set Date and Time using CallableStatement with Timezone as UTC. used the below code. But its not working.

CallableStatement cs = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
cs = localConnection.prepareCall("{CALL updateLocation(?,?,?)}");
while (ResultSet.next()) {
   try {
      cs.setLong(1, remoteResultSet.getLong("id"));
      cs.setString(2, remoteResultSet.getString("place"));
      if (ResultSet.getTimestamp("dateTme") != null) {
         String date = sdf.format(remoteResultSet.getTimestamp("dateTime"));
         Date date1 = sdf.parse(date);
         cs.setTimestamp(3, new Timestamp(date1.getTime()));
         cs.executeUpadte();
      }
   }    

on setTimestamp with callableStatement date and Time is converted back to default Timezone. set the below paramters in jdbc url. does not work.

 useTimezone=true
 useLegacyDatetimeCode=false
 serverTimezone=UTC                 
User123
  • 147
  • 3
  • 13

0 Answers0