📜  java.time.OffsetTime类

📅  最后修改于: 2020-11-14 10:46:38             🧑  作者: Mango


介绍

java.time.OffsetTime类表示与ISO- 8601日历系统中的UTC /格林威治时间偏移的时间,例如10:15:30 + 01:00。

类声明

以下是java.time.OffsetTime类的声明-

public final class OffsetTime
   extends Object
      implements Temporal, TemporalAdjuster, Comparable, Serializable

领域

以下是java.time.OffsetTime类的字段-

  • 静态OffsetTime MAX-支持的最大OffsetTime ’23:59:59.999999999-18:00’。

  • 静态OffsetTime MIN-支持的最小OffsetTime,“ 00: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 OffsetDateTime atDate(LocalDate date)

Combines this time with a date to create a OffsetDateTime.

3 int compareTo(OffsetTime other)

Compares this time to another time.

4 boolean equals(Object obj)

Checks if this time is equal to another time.

5 String format(DateTimeFormatter formatter)

Formats this time using the specified formatter.

6 static OffsetTime from(TemporalAccessor temporal)

Obtains an instance of OffsetTime from a temporal object.

7 int get(TemporalField field)

Gets the value of the specified field from this time as an int.

8 int getHour()

Gets the hour-of-day field.

9 long getLong(TemporalField field)

Gets the value of the specified field from this time as a long.

10 int getMinute()

Gets the minute-of-hour field.

11 int getNano()

Gets the nano-of-second field.

12 ZoneOffset getOffset()

Gets the zone offset, such as ‘+01:00’.

13 int getSecond()

Gets the second-of-minute field.

14 int hashCode()

A hash code for this time.

15 boolean isAfter(OffsetTime other)

Checks if the instant of this OffsetTime is after that of the specified time applying both times to a common date.

16 boolean isBefore(OffsetTime other)

Checks if the instant of this OffsetTime is before that of the specified time applying both times to a common date.

17 boolean isEqual(OffsetTime other)

Checks if the instant of this OffsetTime is equal to that of the specified time applying both times to a common date.

18 boolean isSupported(TemporalField field)

Checks if the specified field is supported.

19 boolean isSupported(TemporalUnit unit)

Checks if the specified unit is supported.

20 OffsetTime minus(long amountToSubtract, TemporalUnit unit)

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

21 OffsetTime minus(TemporalAmount amountToSubtract)

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

22 OffsetTime minusHours(long hoursToSubtract)

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

23 OffsetTime minusMinutes(long minutesToSubtract)

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

24 OffsetTime minusNanos(long nanos)

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

25 OffsetTime minusSeconds(long seconds)

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

26 static OffsetTime now()

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

27 static OffsetTime now(Clock clock)

Obtains the current time from the specified clock.

28 static OffsetTime now(ZoneId zone)

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

29 static OffsetTime of(int hour, int minute, int second, int nanoOfSecond, ZoneOffset offset)

Obtains an instance of OffsetTime from an hour, minute, second, nanosecond and an offset.

30 static OffsetTime of(LocalTime time, ZoneOffset offset)

Obtains an instance of OffsetTime from a local time and an offset.

31 static OffsetTime ofInstant(Instant instant, ZoneId zone)

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

32 static OffsetTime parse(CharSequence text)

Obtains an instance of OffsetTime from a text string such as 10:15:30+01:00.

33 static OffsetTime parse(CharSequence text, DateTimeFormatter formatter)

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

34 OffsetTime plus(long amountToAdd, TemporalUnit unit)

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

35 OffsetTime plus(TemporalAmount amountToAdd)

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

36 OffsetTime plusHours(long hoursToAdd)

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

37 OffsetTime plusMinutes(long minutesToAdd)

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

38 OffsetTime plusNanos(long nanos)

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

39 OffsetTime plusSeconds(long seconds)

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

40 R query(TemporalQuery query)

Queries this time using the specified query.

41 ValueRange range(TemporalField field)

Gets the range of valid values for the specified field.

42 LocalTime toLocalTime()

Gets the LocalTime part of this date-time.

43 String toString()

Outputs this date as a String, such as 10:15.

44 OffsetTime truncatedTo(TemporalUnit unit)

Returns a copy of this OffsetTime with the time truncated.

45 long until(Temporal endExclusive, TemporalUnit unit)

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

46 OffsetTime with(TemporalAdjuster adjuster)

Returns an adjusted copy of this time.

47 OffsetTime with(TemporalField field, long newValue)

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

48 OffsetTime withHour(int hour)

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

49 OffsetTime withMinute(int minute)

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

50 OffsetTime withNano(int nanoOfSecond)

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

51 OffsetTime withOffsetSameInstant(ZoneOffset offset)

Returns a copy of this OffsetTime with the specified offset ensuring that the result is at the same instant on an implied day.

52 OffsetTime withOffsetSameLocal(ZoneOffset offset)

Returns a copy of this OffsetTime with the specified offset ensuring that the result has the same local time.

53 OffsetTime withSecond(int second)

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

方法继承

此类从以下类继承方法-

  • Java.lang.Object