You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2016/02/12 23:32:13 UTC

maven git commit: [MNG-5975] Use Java 7's SimpleDateFormat in CLIReportingUtils#formatTimestamp

Repository: maven
Updated Branches:
  refs/heads/master 184f58ff8 -> 250d2545e


[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/250d2545
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/250d2545
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/250d2545

Branch: refs/heads/master
Commit: 250d2545ea35cdb81883d6e9eb5519c3bbd8abcd
Parents: 184f58f
Author: Michael Osipov <mi...@apache.org>
Authored: Fri Feb 12 23:30:47 2016 +0100
Committer: Michael Osipov <mi...@apache.org>
Committed: Fri Feb 12 23:30:47 2016 +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/250d2545/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 c6ccd97..909c3a6 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 )