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 6943891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:12:54+00:00 2026-05-27T13:12:54+00:00

I am using simple date format in my app in following way in the

  • 0

I am using simple date format in my app in following way in the class:

static SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");

public static myFunction(final String strDate)
{
      Date endDate = null;
 endDate = MyClass.sdf.parse(strDate);
}

I am using FindBugs which is giving the following bug in above code:

“As the JavaDoc states, DateFormats are inherently unsafe for multithreaded use. The detector has found a call to an instance of DateFormat that has been obtained via a static field. This looks suspicous.”

Can someone please explain the bug. I am not able to understand what above message is trying to tell.

Thanks for reading!!

  • 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-27T13:12:55+00:00Added an answer on May 27, 2026 at 1:12 pm

    The others who answered about thread-safety and removing the static keyword from before SimpleDateFormat are correct, though the code you posted with your question is not compilable at all.

    I think this is closer to the code you’re looking for:

    public static Date parseDateStr(final String dateStr) throws ParseException
    {
     SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
     return sdf.parse(dateStr);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this simple date format SimpleDateFormat sdf = new SimpleDateFormat(yyyy-MM-dd HH:mm:ss.SSS Z);
I am using org.apache.commons.validator.routines.DateValidator to validate a date with a simple date pattern dd/mm/yyyy
Using simple type like class A { public int X, Y; } with object
I'm using SimpleDateFormat with the pattern EEE MM/dd hh:mma , passing in the date
I'm using java.text.SimpleDateFormat to parse string representations of date/time values inside an XML document.
This should hopefully be a simple one. When using a date time picker in
I am serializing a class using simple-xml ( http://simple.sourceforge.net/ ) but when i try
I'm trying to create a simple date class, but I get an error on
I'm trying to format a date for a given locale new Locale(mk, MK) .
Short Version: Does anyone know how to do a simple date insert using Doctrine2?

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.