Sorry for that very fundamental question, I believe I understand the solution but want to verify:
When refering to timezones and just how they're usually saved inside a database as well as in a java.util.Date:
- When saving to start dating ? area inside a database, it's timezone agnostic (e.g. always saves in UTC)
- When utilizing a Java Date object the date it's also timezone agnostic
- Time zone is depeneded only if formatting and parsing dates (DB and Java)
- If using Java - it'll make use of the JVM user.timezone to format / parse dates
- If using Java on Home windows - Java will require this in the Regional configurations instantly
- The database timezone (and it is machine's timezone) does not matter towards the Java JDBC client
- The timezone from the Database Server is pertinent just for direct SQL parsing and formating
My questions are:
- Are the suggestions above presumptions correct? some are? all incorect?
- It is possible to reference / official source that certifies this more "formally"?
The assumption are mainly correct for Java. They aren't always correct for databases, as you will find versions.
Java handles timezones with Calendar objects. The java.util.Date object always consists of the UTC value.
Databases generally store and return dates and timestamps (with hour, minutes, etc.) because they are written, no matter the interior format utilized by storage. Should you store 2010-12-25, you'll retrieve exactly the same value no matter time zone from the clients or server.
Some databases possess the TIMESTAMP WITH TIMEZONE data type which stores both timestamp and also the time zone individually.
Dates and timestamps are converted between Java and Database, usually in a fashion that the subclasses of java.util.Date which are used are construed within the JDBC client's time zone.