It's a compilation for personal study
Java SE 8 adds a new API for handling dates and times
LocalDate
Class that manages ** dates **
LocalTime
** Class that manages time without time zone ** Time can be represented to nanosecond accuracy
DateTimeFormatter
Class to change to the specified ** date pattern ** There are three types: "predefined standard formatter", "locally specific formatter", and "formatter with custom pattern" (more complex formatter provided by ** DateTimeFormatterBuilder **).
Duration
Class that manages ** time difference **
Period
A class that manages ** date differences **
ZonedDateTime
** Class that manages time with time zone **
Method used when instantiating by specifying the date
Method to use when you want to instantiate at the current time
A method that converts a string date into date and time information.
Method to convert date information to string Predefined standard formatters are defined in ** java.time.format. DateTimeFormatter class **
Formatter | Example |
---|---|
BASIC_ISO_DATE | 20191213 |
ISO_ZONED_DATE_TIME | 2019-12-13T00:00:00+09:00[Asia/Tokyo] |
ISO_INSTANT | 2019-12-12T15:00:00Z |
ISO_DATE_TIME | 2019-12-13T00:00:00 |
-** ISO_ZONED_DATE_TIME ** and ** ISO_INSTANT ** are the formatters of ** ZonedDateTime **, which represent the time with zones.
** LocalDate ** is a method to calculate ** date difference **, ** LocalTime ** is a method to calculate ** time difference **
** Period ** is a method that calculates ** date difference **, ** Duration ** is a method that calculates ** time difference **
** Durtion ** has methods for each unit you want to get the time difference, such as day, hour, minute, second, nanosecond.
Recommended Posts