• 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
  • Carey Brown
  • salvin francis
  • Claude Moore

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?
Posts: 64184
  • 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

Master Rancher
Posts: 4042
  • 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".
I child proofed my house but they still get in. Distract them with this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!