Classe java.time.LocalDateTime

Introdução

o java.time.LocalDateTime classe representa uma data e hora sem fuso horário no sistema de calendário ISO-8601, como 2007-12-03T10: 15: 30.

Declaração de classe

A seguir está a declaração para java.time.LocalDateTime classe -

public final class LocalDateTime
   extends Object
      implements Temporal, TemporalAdjuster, ChronoLocalDateTime, Serializable

Campo

A seguir estão os campos para java.time.LocalDateTime classe -

  • static LocalDateTime MAX - O máximo LocalDateTime suportado, '+ 999999999-12-31T23: 59: 59.999999999'.

  • static LocalDateTime MIN - O LocalDateTime mínimo compatível, '-999999999-01-01T00: 00: 00'.

Métodos de aula

Sr. Não. Método e Descrição
1 Ajuste temporal em (temporal temporal)

Ajusta o objeto temporal especificado para ter a mesma data e hora que este objeto.

2 OffsetDateTime atOffset (deslocamento ZoneOffset)

Combina esta data e hora com uma hora de deslocamento para criar um OffsetDateTime.

3 ZonedDateTime atZone (zona ZoneId)

Combina esta data e hora com um fuso horário para criar um ZonedDateTime.

4 int compareTo (ChronoLocalDateTime outro)

Compara esta data e hora com outra data e hora.

5 boolean equals (Object obj)

Verifica se esta data e hora é igual a outra data e hora.

6 Formato de string (formatador DateTimeFormatter)

Formata essa data e hora usando o formatador especificado.

7 static LocalDateTime de (TemporalAccessor temporal)

Obtém uma instância de LocalDateTime de um objeto temporal.

8 int get (campo Campo Temporal)

Obtém o valor do campo especificado a partir desta data e hora como um int.

9 int getDayOfMonth ()

Obtém o campo do dia do mês.

10 DayOfWeek getDayOfWeek ()

Obtém o campo do dia da semana, que é uma enumeração DayOfWeek.

11 int getDayOfYear ()

Obtém o campo do dia do ano.

12 int getHour ()

Obtém o campo da hora do dia.

13 long getLong (campo TemporalField)

Obtém o valor do campo especificado a partir desta data e hora como um longo.

14 Mês getMinute ()

Obtém o campo minuto da hora.

15 Mês getMonth ()

Obtém o campo do mês do ano usando a enumeração Mês.

16 int getMonthValue ()

Obtém o campo do mês do ano de 1 a 12.

17 int getNano ()

Obtém o campo de nanossegundos.

18 int getSecond()

Gets the second-of-minute field.

19 int getYear()

Gets the year field.

20 int hashCode()

A hash code for this date-time.

21 boolean isAfter(ChronoLocalDateTime other)

Checks if this date-time is after the specified date-time.

22 boolean isBefore(ChronoLocalDateTime other)

Checks if this date-time is before the specified date-time.

23 boolean isEqual(ChronoLocalDateTime other)

Checks if this date-time is equal to the specified date-time.

24 boolean isSupported(TemporalField field)

Checks if the specified field is supported.

25 boolean isSupported(TemporalUnit unit)

Checks if the specified unit is supported.

26 LocalDateTime minus(long amountToSubtract, TemporalUnit unit)

Returns a copy of this date-time with the specified amount subtracted.

27 LocalDateTime minus(TemporalAmount amountToSubtract)

Returns a copy of this date-time with the specified amount subtracted.

28 LocalDateTime minusDays(long daysToSubtract)

Returns a copy of this LocalDateTime with the specified number of days subtracted.

29 LocalDateTime minusHours(long hoursToSubtract)

Returns a copy of this LocalDateTime with the specified number of hours subtracted.

30 LocalDateTime minusMinutes(long minutesToSubtract)

Returns a copy of this LocalDateTime with the specified number of minutes subtracted.

31 LocalDateTime minusMonths(long monthsToSubtract)

Returns a copy of this LocalDateTime with the specified number of months subtracted.

32 LocalDateTime minusNanos(long nanos)

Returns a copy of this LocalDateTime with the specified number of nanoseconds subtracted.

33 LocalDateTime minusSeconds(long seconds)

Returns a copy of this LocalDateTime with the specified number of seconds subtracted.

34 LocalDateTime minusWeeks(long weeksToSubtract)

Returns a copy of this LocalDateTime with the specified number of weeks subtracted.

35 LocalDateTime minusYears(long yearsToSubtract)

Returns a copy of this LocalDateTime with the specified number of years subtracted.

36 static LocalDateTime now()

Obtains the current date-time from the system clock in the default time-zone.

37 static LocalDateTime now(Clock clock)

Obtains the current date-time from the specified clock.

38 static LocalDateTime now(ZoneId zone)

Obtains the current date-time from the system clock in the specified time-zone.

39 static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute)

Obtains an instance of LocalDateTime from year, month, day, hour and minute, setting the second and nanosecond to zero.

40 static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute, int second)

Obtains an instance of LocalDateTime from year, month, day, hour, minute and second, setting the nanosecond to zero.

41 static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond)

Obtains an instance of LocalDateTime from year, month, day, hour, minute, second and nanosecond.

42 static LocalDateTime of(int year, Month month, int dayOfMonth, int hour, int minute, int second)

Obtains an instance of LocalDateTime from year, month, day, hour, minute and second, setting the nanosecond to zero.

43 static LocalDateTime of(int year, Month month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond)

Obtains an instance of LocalDateTime from year, month, day, hour, minute, second and nanosecond.

44 static LocalDateTime of(LocalDate date, LocalTime time)

Obtains an instance of LocalDateTime from a date and time.

45 static LocalDateTime ofEpochSecond(long epochSecond, int nanoOfSecond, ZoneOffset offset)

Obtains an instance of LocalDateTime from the epoch of 1970-01-01T00:00:00Z.

46 static LocalDateTime ofInstant(Instant instant, ZoneId zone)

Obtains an instance of LocalDateTime from an Instant and zone ID.

47 static LocalDateTime parse(CharSequence text)

Obtains an instance of LocalDateTime from a text string such as 2007-12-03T10:15:30.

48 static LocalDateTime parse(CharSequence text, DateTimeFormatter formatter)

Obtains an instance of LocalDateTime from a text string using a specific formatter.

49 LocalDateTime plus(long amountToAdd, TemporalUnit unit)

Returns a copy of this date-time with the specified amount added.

50 LocalDateTime plus(TemporalAmount amountToAdd)

Returns a copy of this date-time with the specified amount added.

51 LocalDateTime plusDays(long daysToAdd)

Returns a copy of this LocalDateTime with the specified number of days added.

52 LocalDateTime plusHours(long hoursToAdd)

Returns a copy of this LocalDateTime with the specified number of hours added.

53 LocalDateTime plusMinutes(long minutesToAdd)

Returns a copy of this LocalDateTime with the specified number of minutes added.

54 LocalDateTime plusMonths(long monthsToAdd)

Returns a copy of this LocalDateTime with the specified number of months added.

55 LocalDateTime plusNanos(long nanos)

Returns a copy of this LocalDateTime with the specified number of nanoseconds added.

56 LocalDateTime plusSeconds(long seconds)

Returns a copy of this LocalDateTime with the specified number of seconds added.

57 LocalDateTime plusWeeks(long weeksToAdd)

Returns a copy of this LocalDateTime with the specified number of weeks added.

58 LocalDateTime plusYears(long yearsToAdd)

Returns a copy of this LocalDateTime with the specified number of years added.

59 R query(TemporalQuery query)

Queries this date-time using the specified query.

60 ValueRange range(TemporalField field)

Gets the range of valid values for the specified field.

61 LocalDate toLocalDate()

Gets the LocalDate part of this date-time.

62 LocalTime toLocalTime()

Gets the LocalTime part of this date-time.

63 String toString()

Outputs this date as a String, such as 2007-12-03T10:15:30.

64 LocalDateTime truncatedTo(TemporalUnit unit)

Returns a copy of this LocalDateTime with the time truncated.

65 long until(Temporal endExclusive, TemporalUnit unit)

Calculates the amount of time until another date-time in terms of the specified unit.

66 LocalDateTime with(TemporalAdjuster adjuster)

Returns an adjusted copy of this date-time.

67 LocalDateTime with(TemporalField field, long newValue)

Returns a copy of this date-time with the specified field set to a new value.

68 LocalDateTime withDayOfMonth(int dayOfMonth)

Returns a copy of this LocalDateTime with the day-of-month altered.

69 LocalDateTime withDayOfYear(int dayOfYear)

Returns a copy of this LocalDateTime with the day-of-year altered.

70 LocalDateTime withHour(int hour)

Returns a copy of this LocalDateTime with the hour-of-day altered.

71 LocalDateTime withMinute(int minute)

Returns a copy of this LocalDateTime with the minute-of-hour altered.

72 LocalDateTime withMonth(int month)

Returns a copy of this LocalDateTime with the month-of-year altered.

73 LocalDateTime withNano(int nanoOfSecond)

Returns a copy of this LocalDateTime with the nano-of-second altered.

74 LocalDateTime withSecond(int second)

Returns a copy of this LocalDateTime with the second-of-minute altered.

75 LocalDateTime withYear(int year)

Returns a copy of this LocalDateTime with the year altered.

Methods inherited

This class inherits methods from the following classes −

  • Java.lang.Object