From 4aeb9f0bcc88fe98c83119236f839c7c38e063a6 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 9 Dec 2019 17:29:12 +1100 Subject: [PATCH] fix up version display on validator --- .../hl7/fhir/r5/validation}/VersionUtil.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) rename {org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities => org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation}/VersionUtil.java (75%) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtil.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/VersionUtil.java similarity index 75% rename from org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtil.java rename to org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/VersionUtil.java index c9e6a99a7..b4ad10a4c 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtil.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/VersionUtil.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.utilities; +package org.hl7.fhir.r5.validation; /* * #%L @@ -21,8 +21,16 @@ package org.hl7.fhir.utilities; */ import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.time.Duration; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.util.Date; import java.util.Properties; +import org.hl7.fhir.r5.model.InstantType; +import org.hl7.fhir.utilities.Utilities; + import static org.apache.commons.lang3.StringUtils.defaultIfBlank; import static org.apache.commons.lang3.StringUtils.left; @@ -73,7 +81,17 @@ public class VersionUtil { } public static String getVersionString() { - return "Version " + getVersion() + " - Built " + getBuildTime() + " - Git " + left(getBuildNumber(), 12); + return "Version " + getVersion() + " (Git# " + left(getBuildNumber(), 12)+"). Built " + getBuildTime() + " ("+getDurationSinceBuild()+")"; } + private static String getDurationSinceBuild() { + try { + InstantType dt = new InstantType(ourBuildTime); + return Utilities.describeDuration(Duration.ofMillis(new Date().getTime() - dt.getValue().getTime()))+" old"; + } catch (Exception e) { + return "??"; + } + } + + }