-
Recently Browsing 0 members
- No registered users viewing this page.
-
Similar Content
-
SQL Server Management Studio 22.7 brings "What's New" page, T-SQL formatting, and lots more
By Usama Jawad96,
- 3 replies
- 0 views
-
- 4 replies
- 0 views
-
Good news: JetBrains makes another IDE free for non-commercial use
By David Uzondu,
- 0 replies
- 0 views
-
AI's impact on programming language popularity revealed
By zikalify,
- ieee
- programming languages
- (and 7 more)
- 3 replies
- 0 views
-
Microsoft reveals plans for SQL Server Management Studio
By Usama Jawad96,
- microsoft
- sql server management studio
- (and 6 more)
- 12 replies
- 0 views
-
Question
Lord Method Man
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?
Link to comment
https://www.neowin.net/forum/topic/1106623-dates-changing-by-2-days-javasql-server/Share on other sites
3 answers to this question
Recommended Posts