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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:54:44+00:00 2026-06-04T20:54:44+00:00

I’m facing a frustrating problem with static variables in an application I’m debugging (I

  • 0

I’m facing a frustrating problem with static variables in an application I’m debugging (I did not code it myself).

I have a mysql database table called Transits. Transits has a string column (varchar) that holds a date (eventdt) of the format “yyyy/MM/dd HH:mm:ss”.

In my corresponding hibernate class I have a Date variable that will store the value of eventdt. Thus when eventdt is read, the code converts it from a string to a Date.

The code uses SimpleDateFormat in order to do the conversion. The programmer used a static variable to hold the format, but unfortunately made a formatting error:

private static DateFormat df = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");

Leaving it as is, every date stored in the eventdt column that is on the noon hour gets stored in the corresponding Date variable as midnight. Obviously this is undesirable, so I attempted to fix it:

private static DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");

However, the code continues to retain the previous format “yyyy/MM/dd hh:mm:ss”.

I have done some reading up on static variables and did everything I could think of to clear it. I recompiled the code, then redeployed (on Glassfish 3.1.1). I restarted Netbeans (7.1.1) and then rebuilt/redeployed again. I cleared the Netbeans caches and repeated the same process. Then I deleted the entire Glassfish install, rebooted, recreated the domains, cleared the cache again, and went through the same rebuild/redeploy.

I also tried changing the code itself. I thought maybe it could be a threading issue, so I changed the variable to static final:

private static final DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");

Then I changed it so that the static final variable is the format string, and instantiated the DateFormat object in each method where it was needed:

// In class variable block
private static final String DATETIME_FORMAT_PATTERN = "yyyy/MM/dd HH:mm:ss";

// In class methods
DateFormat df = new SimpleDateFormat(DATETIME_FORMAT_PATTERN);

No matter what I’ve done, the same erroneous format “yyyy/MM/dd hh:mm:ss” is retained.

The only thing I can think of that I’ve NOT done yet, is remove and reinstall Netbeans. I’ve read somewhere that updating it helped too. Do I need to go that far in order to clear the old static variable?

I also haven’t tried putting the code in a synchronized block or initializing it ThreadSafe (though I’m not even sure threading is the issue here…)

I would appreciate any guidance in the right direction, as I am running out of ideas. Thanks!

Edit: As requested here is code that uses the DateFormat. lpr is another Hibernate object consolidating Transits table and some other needed tables.

    Date activityDate = null;
    try {
        activityDate = df.parse(getEventdt());
        lpr.setActivityDateTime(activityDate);
    } catch (Exception e) {
        logger.warn("Unable to parse " + getEventdt() + " as a date.");
    }
  • 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-06-04T20:54:46+00:00Added an answer on June 4, 2026 at 8:54 pm

    NetBeans is not likely the culprit. I would guess that the problem lies in deployment, most likely that the jar the static date format is compile to isn’t being deployed.

    You could also have that jar somewhere in the classpath and it’s getting picked up instead of the one you’ve changed.

    Another possibility is that this isn’t the date formatter responsible for the date. I would put a breakpoint on the line and see if you hit it. If you do hit it, is it using the right formatting string?

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a reasonable size flat file database of text documents mostly saved in
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into

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.