diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2014-10-21 16:15:39 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2014-10-22 09:26:25 +0200 |
commit | 99e61ab58b3bc76bbf9e3d9524c79282e046505d (patch) | |
tree | ac19b460c484d0e343f11c3345ce2a61a92e3c94 /sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java | |
parent | 9c03512e5342c127ce904ffa2a8a0e42d1819826 (diff) | |
download | sonarqube-99e61ab58b3bc76bbf9e3d9524c79282e046505d.tar.gz sonarqube-99e61ab58b3bc76bbf9e3d9524c79282e046505d.zip |
SONAR-5698 SONAR-5694 Add business dates finishedAt startedAt and submittedAt to analysis report
Diffstat (limited to 'sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java index edbb024bdb7..3985ddafeb9 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java @@ -20,6 +20,7 @@ package org.sonar.api.utils; import javax.annotation.Nullable; + import java.io.NotSerializableException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -55,6 +56,14 @@ public final class DateUtils { return THREAD_SAFE_DATETIME_FORMAT.format(d); } + public static String formatDateTimeNullSafe(@Nullable Date date) { + if (date == null) { + return ""; + } + + return THREAD_SAFE_DATETIME_FORMAT.format(date); + } + /** * @param s string in format {@link #DATE_FORMAT} * @throws SonarException when string cannot be parsed @@ -123,11 +132,6 @@ public final class DateUtils { static class ThreadSafeDateFormat extends DateFormat { private final String format; - - ThreadSafeDateFormat(String format) { - this.format = format; - } - private final ThreadLocal<Reference<DateFormat>> cache = new ThreadLocal<Reference<DateFormat>>() { @Override public Reference<DateFormat> get() { @@ -140,6 +144,10 @@ public final class DateUtils { } }; + ThreadSafeDateFormat(String format) { + this.format = format; + } + private DateFormat getDateFormat() { return (DateFormat) ((Reference) cache.get()).get(); } |