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

posted @ 2020-07-03 16:01  任国强  阅读(182)  评论(0编辑  收藏  举报