Java – LocalDate, LocalTime, LocalDateTime

These date time classes have a number of methods. Here is the list . . .

Cautionary: Some of these methods are static, some are non-static, some need parameters, some are void, some are typed. See code examples for more

Creation of date time objects – we don’t use “new”

of , parse – of uses parameters while parse uses a single String

now – for the currect date and or time

Formating of date time objects

DateTimeFormatter.ofPattern, format

Getter methods

getDayOfMonth, getDayOfWeek, getDayOfYear, getMonth, getDayOfYear, getMonthValue, getYear, getHour, getMinute, getSecond, getNano

For JDK 9+ toSeconds

For conditions returning boolean

isLeapYear, isEqual, isBefore, isAfter

Date time arithmetic

plusYears, plusMonths, plusDays, plusWeeks, minusYears, minusMonths, minusDays, minusWeeks, plusHours, plusMinutes, plusSeconds, plusNano, minusHours, minusMinutes, minusSeconds, minusNano

Date time calculations

Period.between for years, months and days. Returns a Period object

Duration.between for seconds and nanosecords. Returns a Duration object

LocalTime.ofSecondOfDay. Returns a LocalTime object