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

前端 未结 8 1838
失恋的感觉
失恋的感觉 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 15:04

    Commons Lang has a FastDateFormat object that is thread safe. It only does formatting though, not parsing.

    If you can use commons-lang this might work well for you.

    private static final Date TODAY = Calendar.getInstance().getTime();
    private static final FastDateFormat yymmdd = FastDateFormat.getInstance("yyMMdd");
    
    private String fileName = "file_" + yymmdd.format(TODAY);
    

提交回复
热议问题