diff options
author | Gary Wu <gary.i.wu@huawei.com> | 2017-04-10 12:11:55 -0700 |
---|---|---|
committer | Gary Wu <gary.i.wu@huawei.com> | 2017-04-10 12:14:07 -0700 |
commit | 19340cad94eeaa1b580f7c0c99531de499e8ca14 (patch) | |
tree | af4989c384f5d8c54d01b2fa160e2d53ac71a6f5 /mso-api-handlers/mso-requests-db/src | |
parent | d60f3ad34b20c16d31da8f8a09ed2d9adb10f493 (diff) |
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 <gary.i.wu@huawei.com>
Diffstat (limited to 'mso-api-handlers/mso-requests-db/src')
-rw-r--r-- | mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java | 10 |
1 files changed, 3 insertions, 7 deletions
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); |