Skip to content
Advertisement

In Derby, is there a way to create a database table that has a column that defaults to the UTC timestamp?

I use Derby as a solution for whitebox testing my code. In what will become my production database, I have a column that defaults to the system timestamp in UTC. However; I cannot figure out how to do this in Derby. Is there a way to set up a column like this using Derby? I’ve googled for a good while now and haven’t found anything useful.

Advertisement

Answer

Derby simply does not have a concept of timezones. While I was unable to solve this without complex triggers that called java methods, I found that the solution to my real problem (unit testing) was much simpler. In my unit test, I simply asserted that my returned date was off by the difference between the default timezone and UTC rather than asserting that the dates were equal (or very close).

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement