I need to use DateFormat
object in jxls
beans. If in my class I write the following:
private synchronized DateFormat df = new SimpleDateFormat("dd.MM.yyyy");
Will it be thread-safe? In the same class I have a method:
public void doSomething() {
Map<String,String> beans = new HashMap<String,String>();
beans.put("df",df);
XLSTransformer transformer = new XLSTransformer();
transformer.transformXLS("template.xls", beans, "result.xls");
}
That is called from multiple threads.
If synchronized
field doesn't help in this situation, what can I do to provide thread-safe date formatting from jxls
without creating new DateFormat
object every time?