• 0

Dates changing by 2 days - Java+SQL Server


Question

We're working on a web-based application running JSF on a JBoss server. It deals with a lot of dates which are being problematic.

In the Java beans the dates are handled as Date objects and are being stored in a database. Whenever a Date is stored in the database it is changed to -2 days from what it was in Java. (I.E. If the Date object in the bean is May 8, 2012 the Date in the database will be May 6, 2012; if the Java Date is Jan 1, 2010 the database date is Dec 30, 2009).

When the Dates are retrieved from the database they remain off by 2 days. Obviously there is a conflict between how Java and SQL handle date objects and we would like to find a good fix for it.

Here are a couple work-arounds we are considering should a "proper" solution not exist:

- Add 2 days to each Java date before calling the stored procedure

- Convert the Java date to a string before storing it and have SQL convert the string to a date

Has anyone encountered this before or could explain why it is doing this, and if so is there a correct solution for it?

3 answers to this question

Recommended Posts

This topic is now closed to further replies.
  • Posts

    • Google reshuffles its AI coding team as it struggles to catch Anthropic by Karthik Mudaliar Google is already reorganizing the AI coding “strike team” it created roughly two months ago, as it attempts to find ways to close the gap with Anthropic in one of generative AI’s most commercially important areas. According to The Information, Google DeepMind is expanding the team’s focus to include “midtraining,” rather than concentrating only on coding tools and agents. Midtraining takes place after a model’s broad initial training but before the final stages that prepare it to follow instructions and perform specific tasks. In simple terms, it gives developers another opportunity to expose a model to carefully selected data before it is polished for release. That could help Google improve Gemini’s underlying coding abilities instead of relying only on better prompts, interfaces, or post-training. Previous research has found that midtraining can be particularly effective for code and mathematics, where models must move from general language knowledge to more structured tasks. Google reportedly created the original strike team in April. It was led by Google DeepMind research engineer Sebastian Borgeaud, who previously worked on model pretraining, and focused on complex, long-running programming jobs. Google co-founder Sergey Brin and Google DeepMind chief technology officer Koray Kavukcuoglu were also reportedly involved in the effort. DeepMind researchers were said to believe that Anthropic’s coding tools were outperforming Google’s Gemini models, prompting the company to give the project more attention. Anthropic has made coding a central part of its AI strategy through Claude Code and its Claude model family. The company has continued improving that area, with Claude Opus 4.8 offering upgrades for coding and other agentic tasks, along with the now-unavailable Mythos and Fable models. The reshuffle also comes at a time when Google faces increased competition for AI researchers. Gemini co-lead Noam Shazeer recently announced that he was leaving Google for OpenAI, while two other researchers who contributed to Gemini and DeepMind projects are reportedly preparing to join Anthropic. It remains unclear whether the reorganized team will produce a new public Gemini model or developer product. No release date, team size, or specific performance target has been disclosed. Source: The Information
    • Just remember - Microsoft is a trillion dollar company. They didn't have to raise the price this high. They chose to.
  • Recent Achievements

    • First Post
      kinowa earned a badge
      First Post
    • Rookie
      krychek57 went up a rank
      Rookie
    • Grand Master
      Jaybonaut went up a rank
      Grand Master
    • One Year In
      Philsl earned a badge
      One Year In
    • Dedicated
      Scoobystu earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      413
    2. 2
      +Edouard
      168
    3. 3
      PsYcHoKiLLa
      132
    4. 4
      Xenon
      73
    5. 5
      Michael Scrip
      73
  • Tell a friend

    Love Neowin? Tell a friend!