aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules
diff options
context:
space:
mode:
Diffstat (limited to 'ms/controllerblueprints/modules')
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt7
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt26
2 files changed, 30 insertions, 3 deletions
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt
index b97cb026a..669299534 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt
@@ -24,6 +24,13 @@ package org.onap.ccsdk.cds.controllerblueprints.core
*/
object BluePrintConstants {
+ var APP_NAME = System.getProperty("APPNAME")
+ ?: System.getProperty("APP_NAME")
+ ?: System.getProperty("APPLICATION_NAME")
+ ?: "cds-controller-default"
+
+ const val DATE_TIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
+
const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion"
const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion"
const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion"
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt
index e01ba805d..4fd907a5a 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt
@@ -16,12 +16,32 @@
package org.onap.ccsdk.cds.controllerblueprints.core.utils
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import java.text.SimpleDateFormat
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter
+import java.util.Date
+
+fun controllerDate(): Date {
+ val localDateTime = LocalDateTime.now(ZoneId.systemDefault())
+ return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant())
+}
fun currentTimestamp(): String {
- val now = LocalDateTime.now(ZoneId.systemDefault())
- val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
- return formatter.format(now)
+ val localDateTime = LocalDateTime.now(ZoneId.systemDefault())
+ val formatter = DateTimeFormatter.ofPattern(BluePrintConstants.DATE_TIME_PATTERN)
+ return formatter.format(localDateTime)
+}
+
+/** Parse string date in CDS string format */
+fun String.toControllerDate(): Date {
+ val formatter = SimpleDateFormat(BluePrintConstants.DATE_TIME_PATTERN)
+ return formatter.parse(this)
+}
+
+/** Return date to CDS string format */
+fun Date.currentTimestamp(): String {
+ val formatter = SimpleDateFormat(BluePrintConstants.DATE_TIME_PATTERN)
+ return formatter.format(this)
}