[Java] [Java] Date Related Term Memo

1 minute read

It’s been a while since I was in charge of the server-side project.
Moreover, the environment is db & windows & Java etc. (T, T)
Therefore, I will make a note of terms and other matters related to studying.

the term

1. ISO-8601 calendar system

ISO international standard for date and time notation

Basic format: YYYYMMDDThhmmss + 0900
Example) 20200531T115959 + 0900

2. GMT (Greenwich mean solar time)

Local average solar time in Greenwich, England (0 degrees longitude)
(The time when the average sun is in the south is noon)
Greenwich.png | 経度0度0分0秒の基準子午線.png

Greenwich Observatory Old Main Building

3. UTC (Coordinated Universal Time coordinated)

Basically a cesium atomic clock using cesium atoms

JST (Japan Standard Time)
UTC + 9 hours (time difference of 135 degrees east longitude)

UNIX time (POSIX)
Formal seconds elapsed from UNIX epoch in UTC

  • UNIX epoch: January 1, 1970, 0:00:00 am

Four. Gregorian calendar (new calendar)

It is a calendar system that has been used since October 15, 1582 (Gregorian calendar).
(The 226th Pope Gregory XIII ordered the improvement of the Julian calendar, which was the previous lunar calendar.)

reference

“・ Wikiiso 8601”
(https://ja.wikipedia.org/wiki/ISO_8601)
・ Wiki-GMT (Greenwich Mean Time)
[・ Wiki-UTC (Coordinated Universal Time) (https://ja.wikipedia.org/wiki/%E5%8D%94%E5%AE%9A%E4%B8%96%E7%95%8C%E6% 99% 82)
・ Wiki-UNIX time

JAVA
(Version: 1.8)

1。OffsetDateTime
An invariant representation of date / time using offsets.
Stores all date and time fields to nanosecond precision, as well as offsets from UTC / Greenwich.
Example 1) “2nd October 2007 at 13: 45.30.123456789 +02: 00”
Example 2) Instance generation
of(LocalDateTime date,ZoneOffset zone)
of(LocalDate date, LocalTime time, ZoneOffset zone)

2。LocalDateTime
An immutable date / time object that represents a date / hour (often displayed as year-month-day-hour-minute-second).
You can also access other date and time fields (such as “day of the year”, day of the week, “week number of the year”). Time is expressed to nanosecond precision.
Example 1) “13: 45.30.123456789 on October 2, 2007”
Example 2) Instance generation
of(LocalDate date, LocalTime time)

3。Timestamp
A thin wrapper around java.util.Date that the JDBC API can identify as a SQLTIMESTAMP value.

Example 1) Instance generation
valueOf(LocalDateTime date)

reference

https://docs.oracle.com/javase/jp/8/docs/api/java/time/OffsetDateTime.html
https://docs.oracle.com/javase/jp/8/docs/api/java/time/LocalDateTime.html
https://docs.oracle.com/javase/jp/8/docs/api/java/sql/Timestamp.html

bonus

[[Java] Date / Time API]
(https://www.ne.jp/asahi/hishidama/home/tech/java/datetime.html)
[Swift] Date Royal Road (Date)
[Kotlin] Date How to calculate date and time