diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/review/GenericReviewDAOImpl.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/review/GenericReviewDAOImpl.java index 38fcc9ff2ba..6a4041b0e18 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/review/GenericReviewDAOImpl.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/review/GenericReviewDAOImpl.java @@ -68,8 +68,7 @@ public class GenericReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ? )"; try { int reviewId = -1; - Calendar calendar = Calendar.getInstance(); - Timestamp timestamp = new Timestamp(calendar.getTime().getTime()); + long timestamp = DAOUtil.getCurrentUTCTime(); Connection conn = this.getDBConnection(); try (PreparedStatement statement = conn.prepareStatement(sql, new String[] { "id" })) { statement.setInt(1, tenantId); @@ -78,8 +77,8 @@ public class GenericReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { statement.setInt(4, reviewDTO.getImmediateParentId()); statement.setInt(5, reviewDTO.getRating()); statement.setString(6, reviewDTO.getUsername()); - statement.setTimestamp(7, timestamp); - statement.setTimestamp(8, timestamp); + statement.setLong(7, timestamp); + statement.setLong(8, timestamp); statement.setInt(9, appReleaseId); statement.executeUpdate(); try (ResultSet rs = statement.getGeneratedKeys()) { @@ -158,18 +157,17 @@ public class GenericReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { + "ACTIVE_REVIEW = ? " + "WHERE ID = ? AND TENANT_ID = ?"; try { - Calendar calendar = Calendar.getInstance(); - Timestamp timestamp = new Timestamp(calendar.getTime().getTime()); + long timestamp = DAOUtil.getCurrentUTCTime(); Connection connection = this.getDBConnection(); try (PreparedStatement statement = connection.prepareStatement(sql)){ statement.setString(1, reviewDTO.getContent()); statement.setInt(2, reviewDTO.getRating()); - statement.setTimestamp(3, timestamp); + statement.setLong(3, timestamp); statement.setBoolean(4, isActiveReview); statement.setInt(5, reviewId); statement.setInt(6, tenantId); if (statement.executeUpdate() == 1) { - reviewDTO.setModifiedAt(timestamp); + reviewDTO.setModifiedAt(new Timestamp(timestamp * 1000)); return reviewDTO; } return null; diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/util/DAOUtil.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/util/DAOUtil.java index 289522ae30e..88e53bfe6b7 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/util/DAOUtil.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/util/DAOUtil.java @@ -37,6 +37,7 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Timestamp; import java.time.Instant; import java.util.ArrayList; import java.util.HashMap; @@ -287,8 +288,8 @@ public class DAOUtil { ReviewDTO reviewDTO = new ReviewDTO(); reviewDTO.setId(rs.getInt("ID")); reviewDTO.setContent(rs.getString("COMMENT")); - reviewDTO.setCreatedAt(rs.getTimestamp("CREATED_AT")); - reviewDTO.setModifiedAt(rs.getTimestamp("MODIFIED_AT")); + reviewDTO.setCreatedAt(new Timestamp(rs.getLong("CREATED_AT") * 1000L)); + reviewDTO.setModifiedAt(new Timestamp(rs.getLong("MODIFIED_AT") * 1000L)); reviewDTO.setRootParentId(rs.getInt("ROOT_PARENT_ID")); reviewDTO.setImmediateParentId(rs.getInt("IMMEDIATE_PARENT_ID")); reviewDTO.setUsername(rs.getString("USERNAME"));