fix up version display on validator

This commit is contained in:
Grahame Grieve 2019-12-09 17:29:12 +11:00
parent adc7e377d9
commit 4aeb9f0bcc
1 changed files with 20 additions and 2 deletions

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.utilities; package org.hl7.fhir.r5.validation;
/* /*
* #%L * #%L
@ -21,8 +21,16 @@ package org.hl7.fhir.utilities;
*/ */
import java.io.InputStream; 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 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.defaultIfBlank;
import static org.apache.commons.lang3.StringUtils.left; import static org.apache.commons.lang3.StringUtils.left;
@ -73,7 +81,17 @@ public class VersionUtil {
} }
public static String getVersionString() { 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 "??";
}
}
} }