diff options
Diffstat (limited to 'src/org/traccar/helper/DateBuilder.java')
-rw-r--r-- | src/org/traccar/helper/DateBuilder.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/org/traccar/helper/DateBuilder.java b/src/org/traccar/helper/DateBuilder.java index 77c6821aa..c52210326 100644 --- a/src/org/traccar/helper/DateBuilder.java +++ b/src/org/traccar/helper/DateBuilder.java @@ -25,13 +25,20 @@ public class DateBuilder { public DateBuilder() { this(TimeZone.getTimeZone("UTC")); + } + public DateBuilder(Date time) { + this(time, TimeZone.getTimeZone("UTC")); } public DateBuilder(TimeZone timeZone) { + this(new Date(0), timeZone); + } + + public DateBuilder(Date time, TimeZone timeZone) { calendar = Calendar.getInstance(timeZone); calendar.clear(); - calendar.setTimeInMillis(0); + calendar.setTimeInMillis(time.getTime()); } public DateBuilder setYear(int year) { @@ -90,10 +97,19 @@ public class DateBuilder { return this; } + public DateBuilder addMillis(long millis) { + calendar.setTimeInMillis(calendar.getTimeInMillis() + millis); + return this; + } + public DateBuilder setTime(int hour, int minute, int second) { return setHour(hour).setMinute(minute).setSecond(second); } + public DateBuilder setTimeReverse(int second, int minute, int hour) { + return setHour(hour).setMinute(minute).setSecond(second); + } + public DateBuilder setTime(int hour, int minute, int second, int millis) { return setHour(hour).setMinute(minute).setSecond(second).setMillis(millis); } |