1 46 52 package org.mr.core.util; 53 54 import java.util.GregorianCalendar ; 55 import java.util.Timer ; 56 import java.util.TimerTask ; 57 58 64 public class SystemTime { 65 private static long time = System.currentTimeMillis(); 66 67 71 public static long currentTimeMillis(){ 72 return time; 73 } 74 80 public static long gmtCurrentTimeMillis(){ 81 return time; 82 } 83 84 87 public static void init(){ 88 Timer time = new Timer (true); 89 90 GregorianCalendar cal = new GregorianCalendar (); 91 TimerTask timerTask = new TimerTask (){ 93 public void run(){ 94 SystemTime.sync(); 95 } 96 }; 97 98 time.schedule(timerTask,1000,1000); 99 } 101 104 public static void sync(){ 105 time = System.currentTimeMillis(); 106 } 107 108 109 } | Popular Tags |