mirror of
https://github.com/correl/mage.git
synced 2025-01-13 11:01:58 +00:00
* Fixed a problem with exception by getting the build time for version.
This commit is contained in:
parent
e6896fcca8
commit
1146a38fca
1 changed files with 6 additions and 6 deletions
|
@ -1,13 +1,12 @@
|
||||||
package mage.util;
|
package mage.util;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.time.Instant;
|
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.temporal.TemporalAccessor;
|
||||||
import java.util.jar.Attributes;
|
import java.util.jar.Attributes;
|
||||||
import java.util.jar.Manifest;
|
import java.util.jar.Manifest;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JayDi85
|
* @author JayDi85
|
||||||
|
@ -39,9 +38,10 @@ public class JarVersion {
|
||||||
Manifest manifest = new Manifest(new URL(manifestPath).openStream());
|
Manifest manifest = new Manifest(new URL(manifestPath).openStream());
|
||||||
Attributes attr = manifest.getMainAttributes();
|
Attributes attr = manifest.getMainAttributes();
|
||||||
String buildTime = attr.getValue("Build-Time");
|
String buildTime = attr.getValue("Build-Time");
|
||||||
Instant instant = Instant.parse(buildTime);
|
DateTimeFormatter sourceFormatter = DateTimeFormatter.ofPattern("uuuuMMdd-HHmm").withZone(ZoneOffset.UTC);
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm").withZone(ZoneOffset.UTC);
|
TemporalAccessor ta = sourceFormatter.parse(buildTime);
|
||||||
return formatter.format(instant);
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm").withZone(ZoneOffset.UTC);
|
||||||
|
return formatter.format(ta);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.error("Can't read build time in jar manifest for class " + clazz.getName() + " and path " + manifestPath, e);
|
logger.error("Can't read build time in jar manifest for class " + clazz.getName() + " and path " + manifestPath, e);
|
||||||
return JAR_BUILD_TIME_ERROR;
|
return JAR_BUILD_TIME_ERROR;
|
||||||
|
|
Loading…
Reference in a new issue