Skip to main content

Built-In Date/Time Methods

LocalTime Methods

LocalDateTime atDate(LocalDate date)
String format(String format)
int getHour()
int getMinute()
int getNano()
int getSecond()
boolean isAfter(LocalTime other)
boolean isBefore(LocalTime other)
LocalTime minus(TemporalAmount amount)
LocalTime minusHours(long hours)
LocalTime minusMinutes(long minutes)
LocalTime minusNanos(long nanos)
LocalTime minusSeconds(long seconds)
static LocalTime now()
static LocalTime nowInZone(ZoneId zoneId)
static LocalTime of(int hour, int minute, int second=0, int nano=0)
static LocalTime ofNanoOfDay(long nanoOfDay)
static LocalTime ofSecondOfDay(long second)
static LocalTime parse(String text)
static LocalTime parseWithFormat(String text, String format)
LocalTime plus(TemporalAmount amount)
LocalTime plusHours(long hours)
LocalTime plusMinutes(long minutes)
LocalTime plusNanos(long nanos)
LocalTime plusSeconds(long seconds)
long toNanoOfDay()
int toSecondOfDay()
LocalTime truncatedToHours()
LocalTime truncatedToMicros()
LocalTime truncatedToMillis()
LocalTime truncatedToMinutes()
LocalTime truncatedToSeconds()
Duration until(LocalTime end)
LocalTime withHour(int hour)
LocalTime withMinute(int minute)
LocalTime withNano(int nano)
LocalTime withSecond(int second)

LocalDate Methods

LocalDateTime atStartOfDay()
ZonedDateTime atStartOfDayInZone(ZoneId zoneId)
LocalDateTime atTime(LocalTime time)
String format(String format)
int getDayOfMonth()
String getDayOfWeek()
int getDayOfYear()
String getMonth()
int getMonthValue()
int getYear()
boolean isAfter(LocalDate other)
boolean isBefore(LocalDate other)
boolean isEqual(LocalDate other)
boolean isLeapYear()
int lengthOfMonth()
int lengthOfYear()
LocalDate minus(TemporalAmount amount)
LocalDate minusDays(long days)
LocalDate minusMonths(long months)
LocalDate minusWeeks(long weeks)
LocalDate minusYears(long years)
static LocalDate now()
static LocalDate nowInZone(ZoneId zone)
static LocalDate of(int year, int month, int day)
static LocalDate ofEpochDay(long epochDay)
static LocalDate ofYearDay(int year, int dayOfYear)
static LocalDate parse(String text)
static LocalDate parseWithFormat(String text, String format)
LocalDate plus(TemporalAmount amount)
LocalDate plusDays(long days)
LocalDate plusMonths(long months)
LocalDate plusWeeks(long weeks)
LocalDate plusYears(long years)
long toEpochDay()
Period until(LocalDate end)
LocalDate withDayOfMonth(int day)
LocalDate withDayOfYear(int day)
LocalDate withMonth(int month)
LocalDate withYear(int year)

LocalDateTime Methods

ZonedDateTime atZone(ZoneId zoneId)
String format(String format)
int getDayOfMonth()
String getDayOfWeek()
int getDayOfYear()
int getHour()
int getMinute()
String getMonth()
int getMonthValue()
int getNano()
int getSecond()
int getYear()
boolean isAfter(LocalDateTime other)
boolean isBefore(LocalDateTime other)
boolean isEqual(LocalDateTime other)
LocalDateTime minus(TemporalAmount amount)
LocalDateTime minusDays(long days)
LocalDateTime minusHours(long hours)
LocalDateTime minusMinutes(long minutes)
LocalDateTime minusMonths(long months)
LocalDateTime minusNanos(long nanos)
LocalDateTime minusSeconds(long seconds)
LocalDateTime minusWeeks(long weeks)
LocalDateTime minusYears(long years)
static LocalDateTime now()
static LocalDateTime nowInZone(ZoneId zone)
static LocalDateTime of(int year, int month, int day, int hour, int minute, int second=0, int nano=0)
static LocalDateTime ofDateAndTime(LocalDate date, LocalTime time)
static LocalDateTime ofEpochSecond(long second, int nano=0)
static LocalDateTime ofInstant(Instant instant, ZoneId zoneId)
static LocalDateTime parse(String text)
static LocalDateTime parseWithFormat(String text, String format)
LocalDateTime plus(TemporalAmount amount)
LocalDateTime plusDays(long days)
LocalDateTime plusHours(long hours)
LocalDateTime plusMinutes(long minutes)
LocalDateTime plusMonths(long months)
LocalDateTime plusNanos(long nanos)
LocalDateTime plusSeconds(long seconds)
LocalDateTime plusWeeks(long weeks)
LocalDateTime plusYears(long years)
LocalDate toLocalDate()
LocalTime toLocalTime()
LocalDateTime truncatedToDays()
LocalDateTime truncatedToHours()
LocalDateTime truncatedToMicros()
LocalDateTime truncatedToMillis()
LocalDateTime truncatedToMinutes()
LocalDateTime truncatedToSeconds()
LocalDateTime withDayOfMonth(int day)
LocalDateTime withDayOfYear(int day)
LocalDateTime withHour(int hour)
LocalDateTime withMinute(int minute)
LocalDateTime withMonth(int month)
LocalDateTime withNano(int nano)
LocalDateTime withSecond(int second)
LocalDateTime withYear(int year)

ZonedDateTime Methods

String format(String format)
int getDayOfMonth()
String getDayOfWeek()
int getDayOfYear()
int getHour()
int getMinute()
String getMonth()
int getMonthValue()
int getNano()
int getSecond()
int getYear()
ZoneId getZone()
ZonedDateTime minus(TemporalAmount amount)
ZonedDateTime minusDays(long days)
ZonedDateTime minusHours(long hours)
ZonedDateTime minusMinutes(long minutes)
ZonedDateTime minusMonths(long months)
ZonedDateTime minusNanos(long nanos)
ZonedDateTime minusSeconds(long seconds)
ZonedDateTime minusWeeks(long weeks)
ZonedDateTime minusYears(long years)
static ZonedDateTime now()
static ZonedDateTime nowInZone(ZoneId arg1)
static ZonedDateTime of(int year, int month, int day, int hour, int minute, int second, int nano, ZoneId zoneId)
static ZonedDateTime ofDateAndTime(LocalDate date, LocalTime time, ZoneId zoneId)
static ZonedDateTime ofDateTime(LocalDateTime dateTime, ZoneId zoneId)
static ZonedDateTime ofInstant(Instant instant, ZoneId zoneId)
static ZonedDateTime parse(String text)
static ZonedDateTime parseWithFormat(String text, String format)
ZonedDateTime plus(TemporalAmount amount)
ZonedDateTime plusDays(long days)
ZonedDateTime plusHours(long hours)
ZonedDateTime plusMinutes(long minutes)
ZonedDateTime plusMonths(long months)
ZonedDateTime plusNanos(long nanos)
ZonedDateTime plusSeconds(long seconds)
ZonedDateTime plusWeeks(long weeks)
ZonedDateTime plusYears(long years)
LocalDate toLocalDate()
LocalDateTime toLocalDateTime()
LocalTime toLocalTime()
ZonedDateTime truncatedToDays()
ZonedDateTime truncatedToHours()
ZonedDateTime truncatedToMicros()
ZonedDateTime truncatedToMillis()
ZonedDateTime truncatedToMinutes()
ZonedDateTime truncatedToSeconds()
ZonedDateTime withDayOfMonth(int day)
ZonedDateTime withDayOfYear(int day)
ZonedDateTime withEarlierOffsetAtOverlap()
ZonedDateTime withFixedOffsetZone()
ZonedDateTime withHour(int hour)
ZonedDateTime withLaterOffsetAtOverlap()
ZonedDateTime withMinute(int minute)
ZonedDateTime withMonth(int month)
ZonedDateTime withNano(int nano)
ZonedDateTime withSecond(int second)
ZonedDateTime withYear(int year)
ZonedDateTime withZoneSameInstant(ZoneId zoneId)
ZonedDateTime withZoneSameLocal(ZoneId zoneId)

Instant Methods

ZonedDateTime atZone(ZoneId zoneId)
long getEpochSecond()
int getNano()
boolean isAfter(Instant other)
boolean isBefore(Instant other)
Instant minus(TemporalAmount amount)
Instant minusMillis(long millis)
Instant minusNanos(long nanos)
Instant minusSeconds(long seconds)
static Instant now()
static Instant ofEpochMilli(long milli)
static Instant ofEpochSecond(long second, int nano=0)
static Instant parse(String text)
Instant plus(TemporalAmount amount)
Instant plusMillis(long millis)
Instant plusNanos(long nanos)
Instant plusSeconds(long seconds)
long toEpochMilli()
Instant truncatedToDays()
Instant truncatedToHours()
Instant truncatedToMicros()
Instant truncatedToMillis()
Instant truncatedToMinutes()
Instant truncatedToSeconds()
Instant withMicro(int micro)
Instant withMilli(int milli)
Instant withNano(int nano)

Period Methods

static Period between(LocalDate start, LocalDate end)
int getDays()
int getMonths()
int getYears()
boolean isNegative()
boolean isZero()
Period minus(TemporalAmount other)
Period minusDays(long days)
Period minusMonths(long months)
Period minusYears(long years)
Period multipliedBy(int scalar)
Period negated()
Period normalized()
static Period of(int years, int months, int days)
static Period ofDays(int days)
static Period ofMonths(int months)
static Period ofWeeks(int weeks)
static Period ofYears(int years)
static Period parse(String text)
Period plus(TemporalAmount other)
Period plusDays(long days)
Period plusMonths(long months)
Period plusYears(long years)
long toTotalMonths()
Period withDays(int days)
Period withMonths(int months)
Period withYears(int years)

Duration Methods

Duration abs()
static Duration between(Temporal start, Temporal end)
Duration dividedBy(long amount)
int getNano()
long getSeconds()
boolean isNegative()
boolean isZero()
Duration minus(Duration other)
Duration minusDays(long days)
Duration minusHours(long hours)
Duration minusMillis(long millis)
Duration minusMinutes(long minutes)
Duration minusNanos(long nanos)
Duration minusSeconds(long seconds)
Duration multipliedBy(long amount)
Duration negated()
static Duration ofDays(long days)
static Duration ofHours(long hours)
static Duration ofMillis(long millis)
static Duration ofMinutes(long minutes)
static Duration ofNanos(long nanos)
static Duration ofSeconds(long seconds)
static Duration ofSecondsAndNanos(long seconds, long nanos)
static Duration parse(String text)
Duration plus(Duration other)
Duration plusDays(long days)
Duration plusHours(long hours)
Duration plusMillis(long millis)
Duration plusMinutes(long minutes)
Duration plusNanos(long nanos)
Duration plusSeconds(long seconds)
long toDays()
long toHours()
long toMillis()
long toMinutes()
long toNanos()
Duration withNanos(int nanos)
Duration withSeconds(long seconds)

ZoneId Methods

static List getAvailableZoneIds()
String getId()
static boolean isValid(String zone)
ZoneId normalized()
static ZoneId of(String zone)
static ZoneId systemDefault()