NumberFormatException while parsing date with SimpleDateFormat.parse()

前端 未结 7 1303
我寻月下人不归
我寻月下人不归 2020-12-08 07:11

Have a function that creates a time-only Date object. (why this is required is a long story which is irrelevant in this context but I need to compare to some stuff in XML wo

7条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 07:50

    You can use "sychronized" block to make it thread safe. Something like:

    synchronized (lastUpdatedFormat) {
                date = 
             lastUpdatedFormat.parse(lastUpdatedFormat.format(currentDate));
            }
    

提交回复
热议问题