@@ -0,0 +1,1183 @@
+package com.wizzardo.tools;%0A%0Aimport java.util.Date;%0A%0A/**%0A * @author: moxa%0A * Date: 10/22/13%0A */%0Apublic class TimeTools %7B%0A%0A    public static enum Unit %7B%0A%0A        MILLISECOND(1),%0A        SECOND(1000),%0A        MINUTE(1000 * 60),%0A        HOUR(1000l * 60 * 60),%0A        DAY(1000l * 60 * 60 * 24),%0A        WEEK(1000l * 60 * 60 * 24 * 7);%0A%0A        private final long milliseconds;%0A%0A        private Unit(long milliseconds) %7B%0A            this.milliseconds = milliseconds;%0A        %7D%0A%0A        public long toMilliseconds(long time) %7B%0A            return time * milliseconds;%0A        %7D%0A%0A        public long fromMilliseconds(long time) %7B%0A            return time / milliseconds;%0A        %7D%0A%0A        public long to(long time) %7B%0A            return toMilliseconds(time);%0A        %7D%0A%0A        public long from(long time) %7B%0A            return fromMilliseconds(time);%0A        %7D%0A%0A        public long mod(long time) %7B%0A            return time %25 milliseconds;%0A        %7D%0A    %7D%0A%0A    public static long add(long time, long add, Unit units) %7B%0A        return time + units.to(add);%0A    %7D%0A%0A    public static Date add(Date time, long add, Unit units) %7B%0A        return new Date(add(time.getTime(), add, units));%0A    %7D%0A%0A%7D%0A

add TimeTools