/ Published in: Java
å› ç‚ºSimpleDateFormat是ThreadSafe且耗資æºã€‚
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public abstract class DateUtils { private static final Logger logger = LoggerFactory.getLogger(DateUtils.class ); private static ThreadLocal<simpledateformat> defaultDateFormat = new ThreadLocal<simpledateformat>(); if (null == defaultDateFormat .get()) { } return defaultDateFormat.get(); } try { result = getDefaultDateFormat().parse(date); logger .error( "Can't parse {} to Date", date); } return result; } return getDefaultDateFormat().format(date); } }
URL: http://mactruecolor.blogspot.com/2010/09/improve-simpledateformat-performance.html