/*
 * Timestamp.java
 * 
 * Copyright (C) 2011 IBR, TU Braunschweig
 *
 * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package de.tubs.ibr.dtn.api;

import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

public class Timestamp implements Comparable<Timestamp> {
	
	public final static Long TIMEVAL_CONVERSION = 946684800L;
	
	private Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
	
	public Timestamp(Date d)
	{
		calendar.setTime(d);
	}
	
	public Timestamp(Long dtntimestamp)
	{
		Long utc_timestamp = (dtntimestamp + Timestamp.TIMEVAL_CONVERSION) * 1000;
		calendar.setTimeInMillis(utc_timestamp);
	}
	
	public Date getDate()
	{
		return calendar.getTime();
	}
	
	public Long getValue()
	{
		return (getDate().getTime() / 1000) - Timestamp.TIMEVAL_CONVERSION;
	}

    @Override
    public boolean equals(Object o) {
        if (o instanceof Timestamp) {
            if (calendar != null) {
                return calendar.equals(((Timestamp)o).calendar);
            }
        }
        return super.equals(o);
    }

    @Override
    public int compareTo(Timestamp another) {
        return calendar.compareTo(another.calendar);
    }
}

@@ -1387,20 +1387,17 @@
 ON;%0A%09%7D%0A%0A
-    
+%09
 @Overrid
@@ -1394,28 +1394,25 @@
 %0A%09@Override%0A
-    
+%09
 public boole
@@ -1433,24 +1433,18 @@
 ct o) %7B%0A
-        
+%09%09
 if (o in
@@ -1465,28 +1465,19 @@
 tamp) %7B%0A
-            
+%09%09%09
 if (cale
@@ -1496,24 +1496,12 @@
 ) %7B%0A
-                
+%09%09%09%09
 retu
@@ -1549,40 +1549,19 @@
 r);%0A
-            %7D%0A        %7D%0A        
+%09%09%09%7D%0A%09%09%7D%0A%09%09
 retu
@@ -1584,19 +1584,13 @@
 o);%0A
-    %7D%0A%0A    
+%09%7D%0A%0A%09
 @Ove
@@ -1595,20 +1595,17 @@
 verride%0A
-    
+%09
 public i
@@ -1642,16 +1642,10 @@
 ) %7B%0A
-        
+%09%09
 retu
@@ -1685,16 +1685,13 @@
 endar);%0A
-    
+%09
 %7D%0A%7D%0A

Fix indentation