目录

java.time - OffsetDateTime

介绍 (Introduction)

java.time.OffsetDateTime类表示ISO- java.time.OffsetDateTime UTC/Greenwich的偏移量的日期时间,例如2007-12-03T10:15:30 + 01:00。

类声明

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

public final class OffsetDateTime
   extends Object
      implements Temporal, TemporalAdjuster, Comparable<OffsetDateTime>, Serializable

字段 (Field)

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

  • static OffsetDateTime MAX - 支持的最大OffsetDateTime,'+ 999999999-12-31T23:59:59.999999999 + 18:00'。

  • static OffsetDateTime MIN - 支持的最小OffsetDateTime,' - 999999999-01-01T00:00:00-18:00'。

类方法

Sr.No. 方法和描述
1 Temporal adjustInto(Temporal temporal)

调整指定的时态对象以使其具有与此对象相同的日期和时间。

2 ZonedDateTime atZoneSameInstant(ZoneId zone)

将此日期时间与时区组合以创建ZonedDateTime,以确保结果具有相同的时刻。

3 ZonedDateTime atZoneSimilarLocal(ZoneId zone)

将此日期时间与时区组合以创建ZonedDateTime,以尝试保持相同的本地日期和时间。

4 int compareTo(OffsetDateTime other)

将此日期时间与另一个日期时间进行比较。

5 boolean equals(Object obj)

检查此日期时间是否等于另一个日期时间。

6 String format(DateTimeFormatter formatter)

使用指定的格式化程序格式化此日期时间。

7 (TemporalAccessor temporal)的静态OffsetDateTime

从时态对象获取OffsetDateTime的实例。

8 int get(TemporalField field)

从此日期时间获取指定字段的值作为int。

9 int getDayOfMonth()

获取日期字段。

10 DayOfWeek getDayOfWeek()

获取星期几字段,即枚举DayOfWeek。

11 int getDayOfYear()

获取日期字段。

12 int getHour()

获取当日时间字段。

13 long getLong(TemporalField field)

从此日期时间获取指定字段的值为long。

14 Month getMinute()

获取分钟字段。

15 Month getMonth()

使用Month枚举获取月份字段。

16 int getMonthValue()

获取1到12之间的月份字段。

17 int getNano()

获取纳秒级字段。

18 ZoneOffset getOffset()

获取区域偏移量,例如“+01:00”。

19 int getSecond()

获取第二分钟字段。

20 int getYear()

获取年份字段。

21 int hashCode()

此日期时间的哈希码。

22 boolean isAfter(OffsetDateTime other)

检查此日期时间是否在指定的日期时间之后。

23 boolean isBefore(OffsetDateTime other)

检查此日期时间是否在指定的日期时间之前。

24 boolean isEqual(OffsetDateTime other)

检查此日期时间是否等于指定的日期时间。

25 boolean isSupported(TemporalField field)

检查是否支持指定的字段。

26 boolean isSupported(TemporalUnit unit)

检查指定的单元是否受支持。

27 OffsetDateTime减去(long amountToSubtract,TemporalUnit单位)

返回此日期时间的副本,并减去指定的数量。

28 OffsetDateTime减去(TemporalAmount amountToSubtract)

返回此日期时间的副本,并减去指定的数量。

29

OffsetDateTime minusDays(long daysToSubtract)

返回此OffsetDateTime的副本,并减去指定的天数。

30 OffsetDateTime minusHours(long hoursToSubtract)

返回此OffsetDateTime的副本,并减去指定的小时数。

31 OffsetDateTime minusMinutes(long minutesToSubtract)

返回此OffsetDateTime的副本,并减去指定的分钟数。

32 OffsetDateTime minusMonths(long monthsToSubtract)

返回此OffsetDateTime的副本,并减去指定的月数。

33 OffsetDateTime minusNanos(long nanos)

返回此OffsetDateTime的副本,并减去指定的纳秒数。

34 OffsetDateTime minusSeconds(long seconds)

返回此OffsetDateTime的副本,并减去指定的秒数。

35 OffsetDateTime minusWeeks(long weeksToSubtract)

返回此OffsetDateTime的副本,并减去指定的周数。

36 OffsetDateTime minusYears(long yearsToSubtract)

返回此OffsetDateTime的副本,并减去指定的年数。

37 static OffsetDateTime now()

从默认时区中的系统时钟获取当前日期时间。

38 static OffsetDateTime now(Clock clock)

从指定的时钟获得当前日期时间。

39 static OffsetDateTime now(ZoneId zone)

从指定时区的系统时钟获取当前日期时间。

40 static OffsetDateTime(int year,int month,int dayOfMonth,int hour,int minute,int second,int nanoOfSecond,ZoneOffset offset)

从年,月,日,小时,分钟,秒,纳秒和偏移量获得OffsetDateTime的实例。

41 static OffsetDateTime(LocalDate date,LocalTime time,ZoneOffset offset)

从日期,时间和偏移量中获取OffsetDateTime的实例。

42 static OffsetDateTime(LocalDateTime dateTime,ZoneOffset offset)

从日期时间和偏移量获得OffsetDateTime的实例。

43 静态OffsetDateTime ofInstant(即时即时,ZoneId区域)

从Instant和区域ID获取OffsetDateTime的实例。

44 static OffsetDateTime parse(CharSequence text)

从文本字符串中获取OffsetDateTime的实例,例如2007-12-03T10:15:30。

45 static OffsetDateTime parse(CharSequence text,DateTimeFormatter formatter)

使用特定格式化程序从文本字符串中获取OffsetDateTime的实例。

46 OffsetDateTime plus(long amountToAdd,TemporalUnit unit)

返回此日期时间的副本,并添加指定的数量。

47 OffsetDateTime plus(TemporalAmount amountToAdd)

返回此日期时间的副本,并添加指定的数量。

48 OffsetDateTime plusDays(long daysToAdd)

返回此OffsetDateTime的副本,并添加指定的天数。

49 OffsetDateTime plusHours(long hoursToAdd)

返回此OffsetDateTime的副本,并添加指定的小时数。

50 OffsetDateTime plusMinutes(long minutesToAdd)

返回此OffsetDateTime的副本,并添加指定的分钟数。

51 OffsetDateTime plusMonths(long monthsToAdd)

返回此OffsetDateTime的副本,并添加指定的月数。

52 OffsetDateTime plusNanos(long nanos)

返回此OffsetDateTime的副本,其中添加了指定的纳秒数。

53 OffsetDateTime plusSeconds(长秒)

返回此OffsetDateTime的副本,并添加指定的秒数。

54 OffsetDateTime plusWeeks(long weeksToAdd)

返回此OffsetDateTime的副本,并添加指定的周数。

55 OffsetDateTime plusYears(long yearsToAdd)

返回此OffsetDateTime的副本,其中添加了指定的年数。

56 <R> R query(TemporalQuery<R> query)

使用指定的查询查询此日期时间。

57 ValueRange range(TemporalField field)

获取指定字段的有效值范围。

58 static Comparator <OffsetDateTime> timeLineOrder()

获取一个比较器,它仅根据瞬间比较两个OffsetDateTime实例。

59 long toEpochSecond()

将此日期时间转换为1970-01-01T00:00:00Z纪元的秒数​​。

60 Instant toInstant()

将此日期时间转换为即时。

61 LocalDate toLocalDate()

获取此日期时间的LocalDate部分。

62 LocalDateTime toLocalDateTime()

获取此日期时间的LocalDateTime部分。

63 LocalTime toLocalTime()

获取此日期时间的LocalTime部分。

64 OffsetTime toOffsetTime()

获取此日期时间的OffsetTime部分。

65 String toString()

将此日期输出为字符串,例如2007-12-03T10:15:30。

66 ZonedDateTime toZonedDateTime()

使用偏移量作为区域ID将此日期时间转换为ZonedDateTime。

67 OffsetDateTime truncatedTo(TemporalUnit unit)

返回此OffsetDateTime的副本,并截断时间。

68 long until(Temporal endExclusive, TemporalUnit unit)

根据指定的单位计算到另一个日期时间的时间量。

69 OffsetDateTime with(TemporalAdjuster adjuster)

返回此日期时间的调整副本。

70 OffsetDateTime with(TemporalField field,long newValue)

返回此日期时间的副本,并将指定字段设置为新值。

71 OffsetDateTime withDayOfMonth(int dayOfMonth)

返回此OffsetDateTime的副本,并更改​​日期。

72 OffsetDateTime withDayOfYear(int dayOfYear)

返回此OffsetDateTime的副本,其中包含日期更改。

73 OffsetDateTime withHour(int hour)

返回此OffsetDateTime的副本,并更改​​日期。

74 OffsetDateTime withMinute(int minute)

返回此OffsetDateTime的副本,并更改​​了分钟。

75 OffsetDateTime withMonth(int month)

返回此OffsetDateTime的副本,其中年份已更改。

76 OffsetDateTime withNano(int nanoOfSecond)

返回此OffsetDateTime的副本,并更改​​了纳秒。

77 OffsetDateTime withOffsetSameInstant(ZoneOffset offset)

返回具有指定偏移量的此OffsetDateTime的副本,确保结果处于同一时刻。

78 OffsetDateTime withOffsetSameLocal(ZoneOffset offset)

返回具有指定偏移量的此OffsetDateTime的副本,确保结果具有相同的本地日期时间。

79 OffsetDateTime withSecond(int second)

返回此OffsetDateTime的副本,并在第二分钟更改。

80 OffsetDateTime withYear(int year)

返回此OffsetDateTime的副本,并更改​​年份。

方法继承

该类继承以下类中的方法 -

  • Java.lang.Object
↑回到顶部↑
WIKI教程 @2018