]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/data/Timestamp.java
Version 7, February 2009
[GpsPrune.git] / tim / prune / data / Timestamp.java
index 334bf499e94729ca32d18fdccaaf41c429a5708f..f1d056980de680d5343edf25776ebe56402700d1 100644 (file)
@@ -17,9 +17,10 @@ public class Timestamp
        private String _text = null;
        private String _timeText = null;
 
-       private static DateFormat DEFAULT_DATE_FORMAT = DateFormat.getDateTimeInstance();
-       private static DateFormat DEFAULT_TIME_FORMAT = DateFormat.getTimeInstance();
-       private static DateFormat ISO_8601_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+       private static final DateFormat DEFAULT_DATE_FORMAT = DateFormat.getDateTimeInstance();
+       private static final DateFormat DEFAULT_TIME_FORMAT = DateFormat.getTimeInstance();
+       private static final DateFormat ISO_8601_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+       private static final DateFormat ISO_8601_FORMAT_NOZ = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        private static DateFormat[] ALL_DATE_FORMATS = null;
        private static Calendar CALENDAR = null;
        private static long SECS_SINCE_1970 = 0L;
@@ -53,7 +54,7 @@ public class Timestamp
                        new SimpleDateFormat("HH:mm:ss dd MMM yyyy"),
                        new SimpleDateFormat("dd MMM yyyy HH:mm:ss"),
                        new SimpleDateFormat("yyyy MMM dd HH:mm:ss"),
-                       ISO_8601_FORMAT
+                       ISO_8601_FORMAT, ISO_8601_FORMAT_NOZ
                };
        }
 
@@ -166,6 +167,14 @@ public class Timestamp
                return _valid;
        }
 
+       /**
+        * @param inOther other Timestamp
+        * @return true if this one is after the other
+        */
+       public boolean isAfter(Timestamp inOther)
+       {
+               return _seconds > inOther._seconds;
+       }
 
        /**
         * Calculate the difference between two Timestamps in seconds
@@ -177,13 +186,22 @@ public class Timestamp
                return _seconds - inOther._seconds;
        }
 
+       /**
+        * Add the given number of seconds offset
+        * @param inOffset number of seconds to add/subtract
+        */
+       public void addOffset(long inOffset)
+       {
+               _seconds += inOffset;
+               _text = null;
+       }
 
        /**
         * Add the given TimeDifference to this Timestamp
         * @param inOffset TimeDifference to add
         * @return new Timestamp object
         */
-       public Timestamp addOffset(TimeDifference inOffset)
+       public Timestamp createPlusOffset(TimeDifference inOffset)
        {
                return new Timestamp((_seconds + inOffset.getTotalSeconds()) * 1000L);
        }
@@ -194,7 +212,7 @@ public class Timestamp
         * @param inOffset TimeDifference to subtract
         * @return new Timestamp object
         */
-       public Timestamp subtractOffset(TimeDifference inOffset)
+       public Timestamp createMinusOffset(TimeDifference inOffset)
        {
                return new Timestamp((_seconds - inOffset.getTotalSeconds()) * 1000L);
        }