+ return (_milliseconds - inOther._milliseconds) / 1000L;
+ }
+
+ /**
+ * Calculate the difference between two Timestamps in milliseconds
+ * @param inOther other, earlier Timestamp
+ * @return number of millisseconds since other timestamp
+ */
+ public long getMillisecondsSince(Timestamp inOther)
+ {
+ return _milliseconds - inOther._milliseconds;
+ }
+
+ /**
+ * @param inOther other timestamp to compare
+ * @return true if they're equal to the nearest second
+ */
+ public boolean isEqual(Timestamp inOther)
+ {
+ return getSecondsSince(inOther) == 0L;
+ }
+
+ /**
+ * @param inOther other Timestamp
+ * @return true if this one is before the other
+ */
+ public boolean isBefore(Timestamp inOther)
+ {
+ return getSecondsSince(inOther) < 0L;
+ }
+
+ /**
+ * Add the given number of seconds offset
+ * @param inOffset number of seconds to add/subtract
+ */
+ public void addOffset(long inOffset)
+ {
+ _milliseconds += (inOffset * 1000L);
+ _text = null;
+ }
+
+ /**
+ * Add the given TimeDifference to this Timestamp
+ * @param inOffset TimeDifference to add
+ * @return new Timestamp object
+ */
+ public Timestamp createPlusOffset(TimeDifference inOffset)
+ {
+ return createPlusOffset(inOffset.getTotalSeconds());
+ }
+
+ /**
+ * Add the given number of seconds to this Timestamp
+ * @param inSeconds number of seconds to add
+ * @return new Timestamp object
+ */
+ public Timestamp createPlusOffset(long inSeconds)
+ {
+ return new Timestamp(_milliseconds + (inSeconds * 1000L));
+ }
+
+
+ /**
+ * Subtract the given TimeDifference from this Timestamp
+ * @param inOffset TimeDifference to subtract
+ * @return new Timestamp object
+ */
+ public Timestamp createMinusOffset(TimeDifference inOffset)
+ {
+ return new Timestamp(_milliseconds - (inOffset.getTotalSeconds() * 1000L));