Repository: maven Updated Branches: refs/heads/MNG-5975 [created] 3883ac32a
[MNG-5975] Use Java 7's SimpleDateFormat in CLIReportingUtils#formatTimestamp Project: http://git-wip-us.apache.org/repos/asf/maven/repo Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/3883ac32 Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/3883ac32 Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/3883ac32 Branch: refs/heads/MNG-5975 Commit: 3883ac32ab68b0afa25cae28f2b7541a4fa9ca64 Parents: d413296 Author: Michael Osipov <micha...@apache.org> Authored: Fri Feb 12 23:30:47 2016 +0100 Committer: Michael Osipov <micha...@apache.org> Committed: Sun Jan 22 12:38:41 2017 +0100 ---------------------------------------------------------------------- .../org/apache/maven/cli/CLIReportingUtils.java | 28 +++++--------------- 1 file changed, 6 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven/blob/3883ac32/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java ---------------------------------------------------------------------- diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java index 2397d5d..5f23b13 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java @@ -19,15 +19,15 @@ package org.apache.maven.cli; * under the License. */ -import org.codehaus.plexus.util.Os; -import org.slf4j.Logger; - import java.io.IOException; import java.io.InputStream; +import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.Properties; -import java.util.TimeZone; + +import org.codehaus.plexus.util.Os; +import org.slf4j.Logger; /** * Utility class used to report errors, statistics, application version info, etc. @@ -152,24 +152,8 @@ public final class CLIReportingUtils public static String formatTimestamp( long timestamp ) { - // Manual construction of the tz offset because only Java 7 is aware of ISO 8601 time zones - TimeZone tz = TimeZone.getDefault(); - int offset = tz.getRawOffset(); - - // Raw offset ignores DST, so check if we are in DST now and add the offset - if ( tz.inDaylightTime( new Date( timestamp ) ) ) - { - offset += tz.getDSTSavings(); - } - - // CHECKSTYLE_OFF: MagicNumber - long m = Math.abs( ( offset / ONE_MINUTE ) % 60 ); - long h = Math.abs( ( offset / ONE_HOUR ) % 24 ); - // CHECKSTYLE_ON: MagicNumber - - int offsetDir = (int) Math.signum( (float) offset ); - char offsetSign = offsetDir >= 0 ? '+' : '-'; - return String.format( "%tFT%<tT%s%02d:%02d", timestamp, offsetSign, h, m ); + SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssXXX" ); + return sdf.format( new Date( timestamp ) ); } public static String formatDuration( long duration )