This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes SimpleDateFormat.. not Synchronized Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "SimpleDateFormat.. not Synchronized" Watch "SimpleDateFormat.. not Synchronized" New topic
Author

SimpleDateFormat.. not Synchronized

lakshman lakshman
Greenhorn

Joined: Aug 12, 2004
Posts: 1
Hi how to make SimpleDateFormat.. synchronized...
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8265

The java documentation for SimpleDateFormat states:
Date formats are not synchronized. It is recommended to create separate format instances for each thread.

If you insist on using one instance, create a class that extends SimpleDateFormat and override every method with a synchronized version. Don't forget the methods that are inherited directly from DateFormat.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: SimpleDateFormat.. not Synchronized
 
Similar Threads
Getting problem in SimpleDateFormate
Date type conversion from dd/mm/yyyy to yyyy-mm-dd
SimpleDateFormat
Date Format Problem And Hashtable ......
Converting String to Date Object(mm/dd/yy) format