SimpleDateFormat 非线程安全, 在阿里 Java 开发手册上推荐以下写法 ,可是这种写法参数是写固定的,而实际需要传入指定参数. 比如说只要显示年月日
private ThreadLocal<DateFormat> dateFormat = new ThreadLocal<DateFormat>() { @Override protected DateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); } };
问题: 如何在调用或者初始化时候传入自定义参数.