Call to method of static java.text.DateFormat not advisable?

前端 未结 8 1849
失恋的感觉
失恋的感觉 2020-12-09 14:55

I am receiving a Find Bugs error - call to method of static java.text.DateFormat and I don\'t know the reason why it\'s not good / advisable to be

8条回答
  •  感动是毒
    2020-12-09 14:59

    Are you sure it's not

    private static final DateFormat yymmdd = new SimpleDateFormat("yyMMdd"); 
    

    ? That's what the error message indicates.

    I think what it aims at is the fact that DateFormat is not thread safe, so having an instance as a static field indicates potential race conditions.

提交回复
热议问题