From 19340cad94eeaa1b580f7c0c99531de499e8ca14 Mon Sep 17 00:00:00 2001 From: Gary Wu Date: Mon, 10 Apr 2017 12:11:55 -0700 Subject: Remove unnecessary use of Calendar.getInstance() Calendar.getInstance() is expensive and unnecessary when we only need the system time. This change replaces the uses of Calendar.getInstance() with System.currentTimeMillis(). Change-Id: I476f8850f5eb88d20cf7249cca5bb2e9b671b45a Signed-off-by: Gary Wu --- .../java/org/openecomp/mso/requestsdb/RequestsDatabase.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'mso-api-handlers/mso-requests-db/src/main') diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java index 9abd871b5f..fda4461840 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java @@ -22,7 +22,6 @@ package org.openecomp.mso.requestsdb; import java.sql.Timestamp; import java.util.ArrayList; -import java.util.Calendar; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -98,8 +97,7 @@ public class RequestsDatabase { query.setParameter ("requestStatus", requestStatus); query.setParameter (REQUEST_ID, requestId); query.setParameter ("lastModifiedBy", lastModifiedBy); - Calendar modifyTime = Calendar.getInstance (); - Timestamp modifyTimeStamp = new Timestamp (modifyTime.getTimeInMillis ()); + Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis()); query.setParameter ("modifyTime", modifyTimeStamp); result = query.executeUpdate (); session.getTransaction ().commit (); @@ -125,8 +123,7 @@ public class RequestsDatabase { query.setParameter (REQUEST_ID, requestId); query.setParameter ("progress", progress); query.setParameter ("lastModifiedBy", lastModifiedBy); - Calendar modifyTime = Calendar.getInstance (); - Timestamp modifyTimeStamp = new Timestamp (modifyTime.getTimeInMillis ()); + Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis()); query.setParameter ("modifyTime", modifyTimeStamp); result = query.executeUpdate (); session.getTransaction ().commit (); @@ -150,8 +147,7 @@ public class RequestsDatabase { Query query = session.createQuery ("update InfraActiveRequests set requestStatus = :requestStatus, statusMessage = :statusMessage, progress = :progress, endTime = :endTime, responseBody = :responseBody, lastModifiedBy = :lastModifiedBy where id.requestId = :requestId "); query.setParameter ("requestStatus", requestStatus); query.setParameter ("requestId", requestId); - Calendar endTime = Calendar.getInstance (); - Timestamp endTimeStamp = new Timestamp (endTime.getTimeInMillis ()); + Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis()); query.setParameter ("endTime", endTimeStamp); query.setParameter ("statusMessage", statusMessage); query.setParameter ("progress", progress); -- cgit 1.2.3-korg