This week's book giveaway is in the XML and Related Technologies forum.
We're giving away four copies of Java XML & JSON and have Jeff Friesen on-line!
See this thread for details.
Win a copy of Java XML & JSON this week in the XML and Related Technologies 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
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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: 62803
203
  • 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: 3887
45
  • 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".
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!