Validation request - how do databases and Java store and process time intervals?

My apologies for the extremely simple question, I think I know the answer, but I want to confirm:

When you reference time zones and how they are usually stored in the database and in java.util.Date:

  • When saving the date field in the database, this is the aggregated value of the time zone (for example, it is always saved in UTC format)
  • When using a Java Date object, the date is also temporary agnostic
  • The time zone depends only on the date of formatting and parsing (DB and Java)
  • If you use Java, it will use the JVM user.timezone to format / parse dates
  • If you use Java on Windows, Java will automatically take this from the regional settings.
  • The database timezone (and machine timezone) is not related to the Java JDBC client
  • The database server time zone is relevant only for direct SQL parsing and generation

My questions:

  • Are all the above assumptions correct? some? All of them?
  • Is there a reference / official source that confirms this more "officially"?
+3
source share
1 answer

Assumptions are mostly true for Java. They are not necessarily correct for databases, since there are options.

Java handles time zones with calendar objects. The java.util.Date object always contains a UTC value.

( , ..) , , . 2010-12-25, .

TIMESTAMP WITH TIMEZONE, , .

Java , , , java.util.Date JDBC.

+1

Source: https://habr.com/ru/post/1779209/


All Articles