解决Call to method of static java.text.DateFormat
来源:互联网 发布:淘宝开店模块 编辑:程序博客网 时间:2024/05/22 12:59
今天解决了一个findbug的错误:
Call to method of static java.text.DateFormat in com.pbn.oss.resource.template.input.ws.service.InputTemplateWSServiceImpl.formatDate(Date)
As the JavaDoc states, DateFormats are inherently unsafe for multithreaded use. The detector has found a call to an instance of DateFormat that has been obtained via a static field. This looks suspicous.
初始代码如下:
private static final SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
format.format(new Date());同一个format 多次调用会导致线性不安全,
可以改为:
private static final String COMMON_DATE = "dd/MM/yyyy";SimpleDateFormat format = new SimpleDateFormat(COMMON_DATE);format.format(new Date());
- 解决Call to method of static java.text.DateFormat
- 解决Call to method of static java.text.DateFormat
- Call to method of static java.text.DateFormat
- FindBug:Call to static DateFormat
- 【Findbugs缺陷库】Call to static DateFormat
- 关于Call to static DateFormat 的Findbug警告思考
- FindBugs分析记录[H STCAL]Call to static DateFormat
- cocos JniHelper调用java时总是报 Failed to find static method id of
- Uncaught TypeError: Cannot call method 'replace' of undefined 的解决
- cannot call methods on button prior to initialization; attempted to call method 'toggle' 解决
- Java 的静态函数 及Cannot make a static reference to the non-static method的解决
- JniHelper error: Failed to find static method id of
- Track change of IInterface::asBinder from instance method to static method
- 解决Error: cannot call methods on tabs prior to initialization; attempted to call method 'disable'的方法
- When to use static method in a java class
- JNI - Static method. Method of SuperClass.
- How To Call Run() Method of the Microsoft Script Control in C++
- Android错误解决:java.lang.NoSuchMethodError: No static method encodeBase64String
- 看看一些著名软件都是用什么语言写的
- C# 对记事本的读写
- Linux下文件属性的获取
- 网站收集
- c的整形转换和整形提升
- 解决Call to method of static java.text.DateFormat
- 一些不错的链接
- js函数(parseInt(),indexOf())2012.12.7日学
- C语言中算术运算的隐式类型转换规则
- Oracle 临时表之临时表的应用问题
- CentOS LiveCD LiveDVD DVD 等版本的区别
- 用 snprintf / asprintf 取代不安全的 sprintf
- 找工作的一点点感受
- A very hard mathematic problem(天津online)