Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7065197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:55:38+00:00 2026-05-28T04:55:38+00:00

Recently I encountered many bugs because of SimpleDateFormat is not thread safe. The reason

  • 0

Recently I encountered many bugs because of SimpleDateFormat is not thread safe.

The reason I found out was it was not synchronized properly or new instances were not created for separate threads.

So I thought let’s create a PMD/Checkstyle so that in future if anybody uses SimpleDateFormat he will get some kind of warning about that it’s not thread safe.

I am new to Checkstyle, can anyone describe me how can I achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:55:38+00:00Added an answer on May 28, 2026 at 4:55 am

    FindBugs can output warnings when a DateFormat is defined as a static field. But detecting non-thread-safe usage of a DateFormat is very difficult, because it would need to understand how an object is used. I don’t think writing a CheckStyle rule for this is possible. At least not without detecting a whole lot of false positives.

    Maybe you should just forbid direct usage of DateFormat, and wrap it into a custom class, or mandate the use Apache commons FastDateFormat, which is thread-safe.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently encountered this problem. I found many instances of people asking the question—
I recently encountered a printing issue in Firefox that eventually turned out to be
I recently encountered a problem in my website - some users do not have
I've recently encountered the following exception... java.lang.IllegalStateException: Cannot obtain Writer because OutputStream is already
I recently encountered some code that gcc would not compile without this arg. I
I'm quite new at WPF and recently encountered a problem. I got an ObservableCollection<
I recently encountered a problem with my Profile provider: it wouldn't retrieve profiles correctly
I recently encountered a scenario in which if a set only contained a single
I recently encountered a situation in some code I am working on that doesn't
I recently encountered an index in a database I maintain that was of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.