From e3b0bdaa3133ebe84fe46b5c19ab11b8d558a977 Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Fri, 6 Feb 2015 16:34:43 +0100 Subject: SONAR-5183 timezones - restore Snapshot API --- .../org/sonar/api/database/model/Snapshot.java | 43 +++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'sonar-plugin-api/src') diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/Snapshot.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/Snapshot.java index 2a3a9972653..a83d19fd29b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/Snapshot.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/Snapshot.java @@ -714,6 +714,30 @@ public class Snapshot extends BaseIdentifiable implements Serializable * * @since 2.5 */ + public Snapshot setPeriodDate(int periodIndex, Date date) { + Long time = dateToLong(date); + switch (periodIndex) { + case 1: + period1Date = time; + break; + case 2: + period2Date = time; + break; + case 3: + period3Date = time; + break; + case 4: + period4Date = time; + break; + case 5: + period5Date = time; + break; + default: + throw new IndexOutOfBoundsException("Index of Snapshot.periodDate is between 1 and 5"); + } + return this; + } + public Snapshot setPeriodDateMs(int periodIndex, Long date) { switch (periodIndex) { case 1: @@ -737,7 +761,24 @@ public class Snapshot extends BaseIdentifiable implements Serializable return this; } - public Long getPeriodDate(int periodIndex) { + public Date getPeriodDate(int periodIndex) { + switch (periodIndex) { + case 1: + return longToDate(period1Date); + case 2: + return longToDate(period2Date); + case 3: + return longToDate(period3Date); + case 4: + return longToDate(period4Date); + case 5: + return longToDate(period5Date); + default: + throw new IndexOutOfBoundsException("Index of Snapshot.periodDate is between 1 and 5"); + } + } + + public Long getPeriodDateMs(int periodIndex) { switch (periodIndex) { case 1: return period1Date; -- cgit v1.2.3