轉自:java
http://www.oschina.net/question/12_45856?sort=default&p=2 .net
public class DateUtil { private static final String DATE_FORMT = "yyyy-MM-dd HH:mm:ss"; private static ThreadLocal threadLocal = new ThreadLocal(){ protected synchronized Object initialValue(){ return new SimpleDateFormat(DATE_FORMT); } }; public static DateFormat getDateFormat() { return (DateFormat) threadLocal.get(); } public static Date parse(String textDate) throws ParseException { return getDateFormat().parse(textDate); } }