From 9bda7f63c5d7c06d818b22dd47c4721639abe5e0 Mon Sep 17 00:00:00 2001 From: osh Date: Wed, 3 Jan 2024 14:01:39 +0530 Subject: [PATCH] Fix UTC time issue fixes https://roadmap.entgra.net/issues/10188 --- .../dao/impl/vpp/GenericVppApplicationDAOImpl.java | 5 +++-- .../mgt/core/application/mgt/core/util/DAOUtil.java | 10 ++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/vpp/GenericVppApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/vpp/GenericVppApplicationDAOImpl.java index 38fa090f94..7ff06c41eb 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/vpp/GenericVppApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/vpp/GenericVppApplicationDAOImpl.java @@ -27,6 +27,7 @@ import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; +import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -56,7 +57,7 @@ public class GenericVppApplicationDAOImpl extends AbstractDAOImpl implements Vp try { Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { - long currentTime = System.currentTimeMillis(); + long currentTime = DeviceManagementDAOUtil.getCurrentUTCTime(); stmt.setString(1, userDTO.getClientUserId()); stmt.setString(2, userDTO.getDmUsername()); stmt.setInt(3, tenantId); @@ -117,7 +118,7 @@ public class GenericVppApplicationDAOImpl extends AbstractDAOImpl implements Vp try { Connection conn = this.getDBConnection(); - long updatedTime = System.currentTimeMillis(); + long updatedTime = DeviceManagementDAOUtil.getCurrentUTCTime(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { int x = 0; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/DAOUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/DAOUtil.java index a41f48e1e9..2177c6ad13 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/DAOUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/DAOUtil.java @@ -426,16 +426,10 @@ public class DAOUtil { vppUserDTO.setDmUsername(rs.getString("DM_USERNAME")); } if (rs.getLong("CREATED_TIME") != 0) { - Date date = new Date(rs.getLong("CREATED_TIME")); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String dateString = dateFormat.format(date); - vppUserDTO.setCreatedTime(dateString); + vppUserDTO.setCreatedTime(new Timestamp(rs.getLong("CREATED_TIME") * 1000L).toString()); } if (rs.getLong("LAST_UPDATED_TIME") != 0) { - Date date = new Date(rs.getLong("LAST_UPDATED_TIME")); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String dateString = dateFormat.format(date); - vppUserDTO.setLastUpdatedTime(dateString); + vppUserDTO.setLastUpdatedTime(new Timestamp(rs.getLong("LAST_UPDATED_TIME") * 1000L).toString()); } vppUserDTOS.add(vppUserDTO); }