📅  最后修改于: 2020-11-14 10:46:00             🧑  作者: Mango
java.time.OffsetDateTime类表示日期时间,与ISO- 8601日历系统中的UTC /格林威治时间偏移,例如2007-12-03T10:15:30 + 01:00。
以下是java.time.OffsetDateTime类的声明-
public final class OffsetDateTime
extends Object
implements Temporal, TemporalAdjuster, Comparable, Serializable
以下是java.time.OffsetDateTime类的字段-
static OffsetDateTime MAX-最大支持的OffsetDateTime,“ + 999999999-12-31T23:59:59.999999999 + 18:00”。
静态OffsetDateTime MIN-支持的最小OffsetDateTime’-999999999-01-01T00:00:00-18:00’。
Sr.No. | Method & Description |
---|---|
1 | Temporal adjustInto(Temporal temporal)
Adjusts the specified temporal object to have the same date and time as this object. |
2 | ZonedDateTime atZoneSameInstant(ZoneId zone)
Combines this date-time with a time-zone to create a ZonedDateTime ensuring that the result has the same instant. |
3 | ZonedDateTime atZoneSimilarLocal(ZoneId zone)
Combines this date-time with a time-zone to create a ZonedDateTime trying to keep the same local date and time. |
4 | int compareTo(OffsetDateTime other)
Compares this date-time to another date-time. |
5 | boolean equals(Object obj)
Checks if this date-time is equal to another date-time. |
6 | String format(DateTimeFormatter formatter)
Formats this date-time using the specified formatter. |
7 | static OffsetDateTime from(TemporalAccessor temporal)
Obtains an instance of OffsetDateTime from a temporal object. |
8 | int get(TemporalField field)
Gets the value of the specified field from this date-time as an int. |
9 | int getDayOfMonth()
Gets the day-of-month field. |
10 | DayOfWeek getDayOfWeek()
Gets the day-of-week field, which is an enum DayOfWeek. |
11 | int getDayOfYear()
Gets the day-of-year field. |
12 | int getHour()
Gets the hour-of-day field. |
13 | long getLong(TemporalField field)
Gets the value of the specified field from this date-time as a long. |
14 | Month getMinute()
Gets the minute-of-hour field. |
15 | Month getMonth()
Gets the month-of-year field using the Month enum. |
16 | int getMonthValue()
Gets the month-of-year field from 1 to 12. |
17 | int getNano()
Gets the nano-of-second field. |
18 | ZoneOffset getOffset()
Gets the zone offset, such as ‘+01:00’. |
19 | int getSecond()
Gets the second-of-minute field. |
20 | int getYear()
Gets the year field. |
21 | int hashCode()
A hash code for this date-time. |
22 | boolean isAfter(OffsetDateTime other)
Checks if this date-time is after the specified date-time. |
23 | boolean isBefore(OffsetDateTime other)
Checks if this date-time is before the specified date-time. |
24 | boolean isEqual(OffsetDateTime other)
Checks if this date-time is equal to the specified date-time. |
25 | boolean isSupported(TemporalField field)
Checks if the specified field is supported. |
26 | boolean isSupported(TemporalUnit unit)
Checks if the specified unit is supported. |
27 | OffsetDateTime minus(long amountToSubtract, TemporalUnit unit)
Returns a copy of this date-time with the specified amount subtracted. |
28 | OffsetDateTime minus(TemporalAmount amountToSubtract)
Returns a copy of this date-time with the specified amount subtracted. |
29 |
OffsetDateTime minusDays(long daysToSubtract) Returns a copy of this OffsetDateTime with the specified number of days subtracted. |
30 | OffsetDateTime minusHours(long hoursToSubtract)
Returns a copy of this OffsetDateTime with the specified number of hours subtracted. |
31 | OffsetDateTime minusMinutes(long minutesToSubtract)
Returns a copy of this OffsetDateTime with the specified number of minutes subtracted. |
32 | OffsetDateTime minusMonths(long monthsToSubtract)
Returns a copy of this OffsetDateTime with the specified number of months subtracted. |
33 | OffsetDateTime minusNanos(long nanos)
Returns a copy of this OffsetDateTime with the specified number of nanoseconds subtracted. |
34 | OffsetDateTime minusSeconds(long seconds)
Returns a copy of this OffsetDateTime with the specified number of seconds subtracted. |
35 | OffsetDateTime minusWeeks(long weeksToSubtract)
Returns a copy of this OffsetDateTime with the specified number of weeks subtracted. |
36 | OffsetDateTime minusYears(long yearsToSubtract)
Returns a copy of this OffsetDateTime with the specified number of years subtracted. |
37 | static OffsetDateTime now()
Obtains the current date-time from the system clock in the default time-zone. |
38 | static OffsetDateTime now(Clock clock)
Obtains the current date-time from the specified clock. |
39 | static OffsetDateTime now(ZoneId zone)
Obtains the current date-time from the system clock in the specified time-zone. |
40 | static OffsetDateTime of(int year, int month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond, ZoneOffset offset)
Obtains an instance of OffsetDateTime from a year, month, day, hour, minute, second, nanosecond and offset. |
41 | static OffsetDateTime of(LocalDate date, LocalTime time, ZoneOffset offset)
Obtains an instance of OffsetDateTime from a date, time and offset. |
42 | static OffsetDateTime of(LocalDateTime dateTime, ZoneOffset offset)
Obtains an instance of OffsetDateTime from a date-time and offset. |
43 | static OffsetDateTime ofInstant(Instant instant, ZoneId zone)
Obtains an instance of OffsetDateTime from an Instant and zone ID. |
44 | static OffsetDateTime parse(CharSequence text)
Obtains an instance of OffsetDateTime from a text string such as 2007-12-03T10:15:30. |
45 | static OffsetDateTime parse(CharSequence text, DateTimeFormatter formatter)
Obtains an instance of OffsetDateTime from a text string using a specific formatter. |
46 | OffsetDateTime plus(long amountToAdd, TemporalUnit unit)
Returns a copy of this date-time with the specified amount added. |
47 | OffsetDateTime plus(TemporalAmount amountToAdd)
Returns a copy of this date-time with the specified amount added. |
48 | OffsetDateTime plusDays(long daysToAdd)
Returns a copy of this OffsetDateTime with the specified number of days added. |
49 | OffsetDateTime plusHours(long hoursToAdd)
Returns a copy of this OffsetDateTime with the specified number of hours added. |
50 | OffsetDateTime plusMinutes(long minutesToAdd)
Returns a copy of this OffsetDateTime with the specified number of minutes added. |
51 | OffsetDateTime plusMonths(long monthsToAdd)
Returns a copy of this OffsetDateTime with the specified number of months added. |
52 | OffsetDateTime plusNanos(long nanos)
Returns a copy of this OffsetDateTime with the specified number of nanoseconds added. |
53 | OffsetDateTime plusSeconds(long seconds)
Returns a copy of this OffsetDateTime with the specified number of seconds added. |
54 | OffsetDateTime plusWeeks(long weeksToAdd)
Returns a copy of this OffsetDateTime with the specified number of weeks added. |
55 | OffsetDateTime plusYears(long yearsToAdd)
Returns a copy of this OffsetDateTime with the specified number of years added. |
56 | Queries this date-time using the specified query. |
57 | ValueRange range(TemporalField field)
Gets the range of valid values for the specified field. |
58 | static Comparator Gets a comparator that compares two OffsetDateTime instances based solely on the instant. |
59 | long toEpochSecond()
Converts this date-time to the number of seconds from the epoch of 1970-01-01T00:00:00Z. |
60 | Instant toInstant()
Converts this date-time to an Instant. |
61 | LocalDate toLocalDate()
Gets the LocalDate part of this date-time. |
62 | LocalDateTime toLocalDateTime()
Gets the LocalDateTime part of this date-time. |
63 | LocalTime toLocalTime()
Gets the LocalTime part of this date-time. |
64 | OffsetTime toOffsetTime()
Gets the OffsetTime part of this date-time. |
65 | String toString()
Outputs this date as a String, such as 2007-12-03T10:15:30. |
66 | ZonedDateTime toZonedDateTime()
Converts this date-time to a ZonedDateTime using the offset as the zone ID. |
67 | OffsetDateTime truncatedTo(TemporalUnit unit)
Returns a copy of this OffsetDateTime with the time truncated. |
68 | long until(Temporal endExclusive, TemporalUnit unit)
Calculates the amount of time until another date-time in terms of the specified unit. |
69 | OffsetDateTime with(TemporalAdjuster adjuster)
Returns an adjusted copy of this date-time. |
70 | OffsetDateTime with(TemporalField field, long newValue)
Returns a copy of this date-time with the specified field set to a new value. |
71 | OffsetDateTime withDayOfMonth(int dayOfMonth)
Returns a copy of this OffsetDateTime with the day-of-month altered. |
72 | OffsetDateTime withDayOfYear(int dayOfYear)
Returns a copy of this OffsetDateTime with the day-of-year altered. |
73 | OffsetDateTime withHour(int hour)
Returns a copy of this OffsetDateTime with the hour-of-day altered. |
74 | OffsetDateTime withMinute(int minute)
Returns a copy of this OffsetDateTime with the minute-of-hour altered. |
75 | OffsetDateTime withMonth(int month)
Returns a copy of this OffsetDateTime with the month-of-year altered. |
76 | OffsetDateTime withNano(int nanoOfSecond)
Returns a copy of this OffsetDateTime with the nano-of-second altered. |
77 | OffsetDateTime withOffsetSameInstant(ZoneOffset offset)
Returns a copy of this OffsetDateTime with the specified offset ensuring that the result is at the same instant. |
78 | OffsetDateTime withOffsetSameLocal(ZoneOffset offset)
Returns a copy of this OffsetDateTime with the specified offset ensuring that the result has the same local date-time. |
79 | OffsetDateTime withSecond(int second)
Returns a copy of this OffsetDateTime with the second-of-minute altered. |
80 | OffsetDateTime withYear(int year)
Returns a copy of this OffsetDateTime with the year altered. |
此类从以下类继承方法-