From bc81c8923c53ff26508d97b5b166157c01e644ed Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Thu, 15 Aug 2024 20:21:31 +0530 Subject: [PATCH] Change the return type of the app lifecycle's updated time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the API returns Timestamp object it creates from the Unix timestamp (in milliseconds), but its string representation depends on the JVM’s default timezone. Therefore it returns timestamp based on JVM's timezone. Since it is required to return UTC time, changed the data type and returns the long value. With this improvement it is guaranteed that client gets the UTC time of the app lifecycle's updated time. --- .../mgt/core/application/mgt/common/LifecycleState.java | 8 ++++---- .../impl/lifecyclestate/GenericLifecycleStateDAOImpl.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/LifecycleState.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/LifecycleState.java index b72d169253..53c839c6d8 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/LifecycleState.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/LifecycleState.java @@ -45,8 +45,8 @@ public class LifecycleState { private String updatedBy; @ApiModelProperty(name = "updatedAt", - value = "Timestamp of the lifecycle has been updated") - private Timestamp updatedAt; + value = "The seconds from the epoch of 1970-01-01T00:00:00Z that the lifecycle has been updated") + private Long updatedAt; @ApiModelProperty(name = "reasonForChange", value = "Reason for the application release lifecycle change from previous state to current state.") @@ -76,11 +76,11 @@ public class LifecycleState { this.updatedBy = updatedBy; } - public Timestamp getUpdatedAt() { + public Long getUpdatedAt() { return updatedAt; } - public void setUpdatedAt(Timestamp updatedAt) { + public void setUpdatedAt(Long updatedAt) { this.updatedAt = updatedAt; } 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/lifecyclestate/GenericLifecycleStateDAOImpl.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/lifecyclestate/GenericLifecycleStateDAOImpl.java index ac16c04084..f491a5a657 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/lifecyclestate/GenericLifecycleStateDAOImpl.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/lifecyclestate/GenericLifecycleStateDAOImpl.java @@ -274,7 +274,7 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif lifecycleState = new LifecycleState(); lifecycleState.setCurrentState(rs.getString("CURRENT_STATE")); lifecycleState.setPreviousState(rs.getString("PREVIOUS_STATE")); - lifecycleState.setUpdatedAt(new Timestamp(rs.getLong("UPDATED_AT"))); + lifecycleState.setUpdatedAt(rs.getLong("UPDATED_AT")); lifecycleState.setUpdatedBy(rs.getString("UPDATED_BY")); } } catch (SQLException e) { @@ -300,7 +300,7 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif LifecycleState lifecycleState = new LifecycleState(); lifecycleState.setCurrentState(rs.getString("CURRENT_STATE")); lifecycleState.setPreviousState(rs.getString("PREVIOUS_STATE")); - lifecycleState.setUpdatedAt(new Timestamp(rs.getLong("UPDATED_AT") * 1000L)); + lifecycleState.setUpdatedAt(rs.getLong("UPDATED_AT")); lifecycleState.setUpdatedBy(rs.getString("UPDATED_BY")); lifecycleStates.add(lifecycleState); }