Is Joda-Time DateTimeFormatter class thread safe?

JavaThread SafetyJodatimeDate Format

Java Problem Overview


Is the Joda-Time DateTimeFormatter class thread safe? Once I get an instance from DateTimeFormat.forPattern, can its various parse methods be called by multiple threads? DateTimeFormatter's Javadocs makes no mention of thread safety.

Java Solutions


Solution 1 - Java

Yes, it is:

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

and so is the Java 8 version

> Implementation Requirements: This class is immutable and thread-safe.

Solution 2 - Java

A quick look at the code shows there isn't any mutable shared state in DateTimeFormatter, which would make it thread safe.

Solution 3 - Java

Found this question on top of google's answers when checking for Java's java.time.format.DateTimeFormatter thread safety

Java's own DateTimeFormatter is also thread-safe, as the documentation states:

> This class is immutable and thread-safe

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSteve KuoView Question on Stackoverflow
Solution 1 - JavaErre EfeView Answer on Stackoverflow
Solution 2 - JavaMark ElliotView Answer on Stackoverflow
Solution 3 - JavaDariuszView Answer on Stackoverflow