Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Mismatch between what's being stored in my H2 database & my Dev environment database  RSS feed

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


My Spring Boot application contains some API's which inserts some data into a series of databases.

I am writing automated tests that send input XML's to these API's & populate a H2 (in-memory) database.

All of my tests are running, and the majority of these are running except for some smalldatetime fields.

The value that we are expecting to be populating the H2 with is 01/01/1900 00:00:00:000, but the value that is being populated is 01/01/1970 00:00:00:000.

Strangely, when I send the same input XML to the Dev environment, the Dev DB is being populated with the correct value (1900)

Does anyone know what could be causing this issue?
 
Marshal
Posts: 61715
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please show us how you are getting those date‑times. Are you using a spreadsheet anywhere? 1st January 1970 is called the epoch, and it is the date you would get if you set the long representing milliseconds in a java.util.Date to 0.
1st January 19901900 is one of the default “zero” settings on a spreadsheet. You can also get it from a Date object as shown on my JShell:-

Campbell's JShell wrote:jshell> new Date(0L)
$6 ==> Thu Jan 01 01:00:00 GMT 1970

jshell> new Date(0, 0, 0)
$7 ==> Sun Dec 31 00:00:00 GMT 1899

jshell> new Date(0, 0, 1)
$8 ==> Mon Jan 01 00:00:00 GMT 1900

 
Rancher
Posts: 3748
40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the databse in the dev environment?

H2 uses 1/1/1970 as the epoch (it's written in Java so uses the same).

SQL Server, on the other hand, uses 1/1/1900 as "zero".
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
Download Free Java APIs to Work with Office Files and PDF
htttp://www.e-iceblue.com/free-apis.html
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!