I have a question about thread safety. From what I have been told, SimpleDateFormat is not thread safe. I was wondering what effects it would have if I use it the following way in my spring controller:
private final static SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd yyyy", Locale.US);
Later in my of my controller functions I use it as follows:
try {
changedate = changedate.substring(0, 15);
calcDate = dateFormat.parse(changedate);
} catch (ParseException e2) {
logger.error("Date Parsing Problem", e2);
}
calcDate then gets added to my model object and a ModelAndView is returned.
So what kind of problems will I see using it this way? Would simply removing the static keyword fix any issues because then each thread will use its own instance of dateFormat? Any clarity on this subejct in regards to thread safety would be much appreciated.
Thanks