From 8a9619bf805e047b2c44236f032d7f7b613c6f83 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Tue, 8 Jan 2019 11:00:26 +0400 Subject: [PATCH] Fixed build time --- Mage/src/main/java/mage/util/JarVersion.java | 11 +++++++---- pom.xml | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Mage/src/main/java/mage/util/JarVersion.java b/Mage/src/main/java/mage/util/JarVersion.java index d88439c0a2..5c494ed13b 100644 --- a/Mage/src/main/java/mage/util/JarVersion.java +++ b/Mage/src/main/java/mage/util/JarVersion.java @@ -1,12 +1,13 @@ package mage.util; +import org.apache.log4j.Logger; + import java.net.URL; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalAccessor; import java.util.jar.Attributes; import java.util.jar.Manifest; -import org.apache.log4j.Logger; /** * @author JayDi85 @@ -19,6 +20,7 @@ public class JarVersion { public static String getBuildTime(Class clazz) { // build time info inserted by maven on jar build phase (see root pom.xml) + String resultFormat = "uuuu-MM-dd HH:mm"; String className = clazz.getSimpleName() + ".class"; String classPath = clazz.getResource(className).toString(); @@ -38,10 +40,11 @@ public class JarVersion { Manifest manifest = new Manifest(new URL(manifestPath).openStream()); Attributes attr = manifest.getMainAttributes(); String buildTime = attr.getValue("Build-Time"); - DateTimeFormatter sourceFormatter = DateTimeFormatter.ofPattern("uuuuMMdd-HHmm").withZone(ZoneOffset.UTC); + // default maven format: yyyy-MM-dd'T'HH:mm:ss'Z' or see maven.build.timestamp.format in pom file + DateTimeFormatter sourceFormatter = DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss'Z'").withZone(ZoneOffset.UTC); TemporalAccessor ta = sourceFormatter.parse(buildTime); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm").withZone(ZoneOffset.UTC); - return formatter.format(ta); + DateTimeFormatter resultFormatter = DateTimeFormatter.ofPattern(resultFormat).withZone(ZoneOffset.UTC); + return resultFormatter.format(ta); } catch (Throwable e) { logger.error("Can't read build time in jar manifest for class " + clazz.getName() + " and path " + manifestPath, e); return JAR_BUILD_TIME_ERROR; diff --git a/pom.xml b/pom.xml index e4f8e8f1ee..c29fc8e2e1 100644 --- a/pom.xml +++ b/pom.xml @@ -90,6 +90,7 @@ 1.4.32 UTF-8 + yyyy-MM-dd'T'HH:mm:ss'Z'