@@ -25,6 +25,9 @@ import java.util.Map;
*/
public class DateFormats {
+ /**
+ * SimpleDateFormat 非线程安全,结合 WriterBuffer 中的 ThreadLocal 才能确保线程安全
+ */
private Map<String, SimpleDateFormat> map = new HashMap<String, SimpleDateFormat>(16, 0.25F);
public SimpleDateFormat getDateFormat(String datePattern) {
@@ -58,6 +58,13 @@ public abstract class Writer {
String str = formats.getDateFormat(datePattern).format(date);
write(str, 0, str.length());
}
+
+ * 格式化输出 LocalDateTime、LocalDate、LocalTime
+ public void write(java.time.temporal.Temporal temporal, String pattern) throws IOException {
+ write(com.jfinal.kit.TimeKit.getFormatter(pattern).format(temporal));
+ }