Author: xor
Date: 2009-02-27 15:33:51 +0000 (Fri, 27 Feb 2009)
New Revision: 25859

Modified:
   trunk/freenet/src/freenet/support/CurrentTimeUTC.java
Log:
Doh. class Calendar really sucks: clear() does not update the time but sets it 
to unix time 0. You need to use System.currentTimeMillis() for updating it. Fix 
this.

Modified: trunk/freenet/src/freenet/support/CurrentTimeUTC.java
===================================================================
--- trunk/freenet/src/freenet/support/CurrentTimeUTC.java       2009-02-27 
15:21:18 UTC (rev 25858)
+++ trunk/freenet/src/freenet/support/CurrentTimeUTC.java       2009-02-27 
15:33:51 UTC (rev 25859)
@@ -20,38 +20,32 @@
 public class CurrentTimeUTC {
 
        private static final GregorianCalendar mCalendar = new 
GregorianCalendar(TimeZone.getTimeZone("UTC"));
-       
+
        public static Date get() {
-               synchronized(mCalendar) {
-                       mCalendar.clear();
-                       return mCalendar.getTime();
-               }
+               return new Date();
        }
-       
+
        public static long getInMillis() {
-               synchronized(mCalendar) {
-                       mCalendar.clear();
-                       return mCalendar.getTimeInMillis();
-               }
+               return System.currentTimeMillis();
        }
-       
+
        public static int getYear() {
                synchronized(mCalendar) {
-                       mCalendar.clear();
+                       mCalendar.setTimeInMillis(System.currentTimeMillis());
                        return mCalendar.get(Calendar.YEAR);
                }
        }
-       
+
        public static int getMonth() {
                synchronized(mCalendar) {
-                       mCalendar.clear();
+                       mCalendar.setTimeInMillis(System.currentTimeMillis());
                        return mCalendar.get(Calendar.MONTH);
                }
        }
-       
+
        public static int getDayOfMonth() {
                synchronized(mCalendar) {
-                       mCalendar.clear();
+                       mCalendar.setTimeInMillis(System.currentTimeMillis());
                        return mCalendar.get(Calendar.DAY_OF_MONTH);
                }
        }

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to