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 2397d5d033..214704b9ea 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% 0 ) { + // Length 11+ chars format = "%d d %02d:%02d h"; } else if ( h > 0 ) { + // Length 7 chars format = "%2$02d:%3$02d h"; } else if ( m > 0 ) { + // Length 9 chars format = "%3$02d:%4$02d min"; } else { + // Length 7-8 chars format = "%4$d.%5$03d s"; }