From 31d3e8ca7e8a489ade06a98efaaf4684b3124f51 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 8 Aug 2013 14:05:22 +0200 Subject: SONAR-4564 SONAR-4563 fix detection of new issues since previous analysis --- .../java/org/sonar/api/issue/internal/DefaultIssue.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'sonar-plugin-api/src') diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java index 739ec339918..b739523a0d7 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java @@ -29,6 +29,7 @@ import com.google.common.collect.Maps; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; +import org.apache.commons.lang.time.DateUtils; import org.sonar.api.issue.Issue; import org.sonar.api.issue.IssueComment; import org.sonar.api.rule.RuleKey; @@ -37,10 +38,7 @@ import org.sonar.api.rule.Severity; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import java.io.Serializable; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; /** * PLUGINS MUST NOT BE USED THIS CLASS, EXCEPT FOR UNIT TESTING. @@ -233,7 +231,8 @@ public class DefaultIssue implements Issue { } public DefaultIssue setCreationDate(Date d) { - this.creationDate = d; + // d is not marked as Nullable but we still allow null parameter for unit testing. + this.creationDate = (d != null ? DateUtils.truncate(d, Calendar.SECOND) : null); return this; } @@ -243,7 +242,7 @@ public class DefaultIssue implements Issue { } public DefaultIssue setUpdateDate(@Nullable Date d) { - this.updateDate = d; + this.updateDate = (d != null ? DateUtils.truncate(d, Calendar.SECOND) : null); return this; } @@ -253,7 +252,7 @@ public class DefaultIssue implements Issue { } public DefaultIssue setCloseDate(@Nullable Date d) { - this.closeDate = d; + this.closeDate = (d != null ? DateUtils.truncate(d, Calendar.SECOND) : null); return this; } -- cgit v1.2.3