Fixing thread safety issue with date formatting