package org.owasp.appsensor.util;

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

/**
 * Helper class for Date/time related utility methods
 * 
 * @author John Melton (jtmelton@gmail.com) http://www.jtmelton.com/
 */
public class DateUtils {

	/**
	 * Helper method to grab current time. Returns current 
	 * timestamp used for events/attacks, etc. 
	 * 
	 * @return current time represented as long (unix timestamp)
	 */
	public static long getCurrentTime() {
		TimeZone tz = TimeZone.getDefault();
		Calendar cal = Calendar.getInstance(tz);
		Date date = cal.getTime();
		long currentTime = date.getTime();
		return currentTime;
	}
	
}

@@ -39,26 +39,30 @@
 ort 
-jav
+org.jod
 a.
-u
 ti
-l.Calendar
+me.DateTime
 ;%0Aim
@@ -70,22 +70,34 @@
 ort 
-jav
+org.jod
 a.
-u
 ti
-l
+me
 .Date
+TimeZone
 ;%0Aim
@@ -105,25 +105,36 @@
 ort 
-java.util.TimeZon
+org.joda.time.MutableDateTim
 e;%0A%0A
@@ -299,398 +299,599 @@
 %7B%0A%0A%09
-/**%0A%09 * Helper method to grab current time. Returns current %0A%09 * timestamp used for events/attacks, etc. %0A%09 * %0A%09 * @return current time represented as long (unix timestamp)%0A%09 */%0A%09public static long getCurrentTime() %7B%0A%09%09TimeZone tz = TimeZone.getDefault();%0A%09%09Calendar cal = Calendar.getInstance(tz);%0A%09%09Date date = cal.getTime();%0A%09%09long currentTime = date.g
+public static DateTime getCurrentTimestamp() %7B%0A%09%09return new DateTime(DateTimeZone.UTC);%0A%09%7D%0A%09%0A%09public static String getCurrentTimestampAsString() %7B%0A%09%09return getCurrentTimestamp().toString();%0A%09%7D%0A%09%0A%09public static DateTime fromString(String rfc3339Timestamp) %7B%0A%09%09if (rfc3339Timestamp == null) %7B%0A%09%09%09return null;%0A%09%09%7D%0A%09%09%0A%09%09DateTime dateTime = new DateTime(rfc3339Timestamp, DateTimeZone.UTC);%0A%09%09return dateTime;%0A%09%7D%0A%09%0A%09public static DateTime epoch() %7B%0A%09%09 MutableDateTime epoch = new MutableDateTime();%0A%09%09 %0A%09     epoch.setDate(0); %0A%09     epoch.s
 etTime(
+0
 );%0A%09
-%09return current
+        %0A%09     return epoch.toDate
 Time
+()
 ;%0A%09%7D%0A
-%09%0A
 %7D%0A

change date utilities to support rfc 3339 date / time