I'm sure that if you don't use that static
instance of SimpleDateFormat
you will have no problem:
public static String getCurrentDateTime() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d = new Date();
String datetime = sdf.format(d);
return datetime;
}
See these links:
Why is Java's SimpleDateFormat not thread-safe?
"Java DateFormat is not threadsafe" what does this leads to?