ThreadSafe : java.text.SimpleDateFormat vs. com.thoughtworks.xstream.core.util.ThreadSafeSimpleDateFormat

public static String formatDateStr (Date date) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return formatDateStr(date, simpleDateFormat);
}

public static String formatDateStrThreadSafe (Date date) {
    ThreadSafeSimpleDateFormat format = new ThreadSafeSimpleDateFormat("yyyy-MM-dd HH:mm:ss", TimeZone.getTimeZone("UTC"), 0, 5, false);
    return format.format(date);
}

https://www.cnblogs.com/icewee/articles/2017690.html

原文地址:https://www.cnblogs.com/rgqancy/p/13230952.html