Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is org.joda.time.DateTimeFormat thread safe?

I have an instance of an org.joda.time.DateTimeFormat in an object :

   object TimeRange {
    lazy val dateFormat = DateTimeFormat.forPattern("YYYY-MM-dd")
   }

My API is asynchronous (using Finagle Future) and different threads may want to access my dateFormat to format date using function dateFormat.parseDateTime("2013-07-01"). My question is: how can I be sure that this method invocation will be thread safe ? Can we assume that all method invocations without side effects are thread safe ? Does it depend on the specific implementation of DateTimeFormat ?

Thanks,

like image 675
Benoit Guigal Avatar asked Feb 17 '23 00:02

Benoit Guigal


1 Answers

From the doc:

DateTimeFormat is thread-safe and immutable, and the formatters it returns are as well.

like image 177
Brian Agnew Avatar answered Feb 27 '23 13:02

Brian Agnew