@@ -0,0 +1,1491 @@
+/*%0A * The MIT License (MIT)%0A * Copyright (c) 2014 longkai%0A * The software shall be used for good, not evil.%0A */%0Apackage org.catnut.util;%0A%0Aimport android.util.Log;%0A%0Aimport java.text.ParseException;%0Aimport java.text.SimpleDateFormat;%0Aimport java.util.Date;%0Aimport java.util.Locale;%0A%0A/**%0A * %E5%A4%84%E7%90%86%E5%BE%AE%E5%8D%9A%E6%97%B6%E9%97%B4%E8%BD%AC%E6%8D%A2%0A *%0A * @author longkai%0A */%0Apublic class DateTime %7B%0A%0A%09private static final String TAG = %22DateTime%22;%0A%0A%09/**%0A%09 * %E5%B0%86%E5%BE%AE%E5%8D%9A%E6%96%87%E6%9C%AC%E8%BD%AC%E6%8D%A2%E4%B8%BA%E6%97%B6%E9%97%B4%0A%09 *%0A%09 * @return %E8%8B%A5%E5%A4%B1%E8%B4%A5%EF%BC%8C%E8%BF%94%E5%9B%9Enull%0A%09 */%0A%09public static Date parse(String string) %7B%0A%09%09try %7B%0A%09%09%09return sSafeDateFormat.get().parse(string);%0A%09%09%7D catch (ParseException e) %7B%0A%09%09%09Log.e(TAG, %22parsing string %5B%22 + string + %22%5D to date error!%22, e);%0A%09%09%09return null;%0A%09%09%7D%0A%09%7D%0A%0A%09/**%0A%09 * %E5%B0%86%E6%96%87%E6%9C%AC%E8%BD%AC%E6%8D%A2%E4%B8%BA%E6%97%B6%E9%97%B4%0A%09 *%0A%09 * @return %E8%8B%A5%E5%A4%B1%E8%B4%A5%EF%BC%8C%E8%BF%94%E5%9B%9E0%0A%09 */%0A%09public static long getTimeMills(String string) %7B%0A%09%09try %7B%0A%09%09%09return sSafeDateFormat.get().parse(string).getTime();%0A%09%09%7D catch (ParseException e) %7B%0A%09%09%09Log.e(TAG, %22parsing string %5B%22 + string + %22%5D to millis error!%22, e);%0A%09%09%09return 0L;%0A%09%09%7D%0A%09%7D%0A%0A%09private static ThreadLocal%3CSimpleDateFormat%3E sSafeDateFormat = new ThreadSafeDateFormat();%0A%0A%09public static class ThreadSafeDateFormat extends ThreadLocal%3CSimpleDateFormat%3E %7B%0A%0A%09%09@Override%0A%09%09protected SimpleDateFormat initialValue() %7B%0A%09%09%09return new SimpleDateFormat(%22EEE MMM d HH:mm:ss Z yyyy%22, Locale.ENGLISH);%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public SimpleDateFormat get() %7B%0A%09%09%09return super.get();%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public void set(SimpleDateFormat value) %7B%0A%09%09%09super.set(value);%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public void remove() %7B%0A%09%09%09super.remove();%0A%09%09%7D%0A%09%7D%0A%7D%0A

添加了一个日期处理类，线程安全的