java.time.OffsetDateTime类

简介

java.time.OffsetDateTime 类表示在ISO-8601日历系统中与UTC/Greenwich的偏移量的日期时间,例如as 2007-12-03T10:15:30 + 01:00.

类声明

以下是 java.time的声明.OffsetDateTime class :

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

Field

以下是 java.time.OffsetDateTime  class :

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

  • 静态OffsetDateTime MIN &减去;支持的最小OffsetDateTime,' -  999999999-01-01T00:00:00-18:00'.

类方法

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

将指定的时间对象调整为具有相同的日期和时间这个对象.

2ZonedDateTime atZoneSameInstant(ZoneId zone)

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

3ZonedDateTime atZoneSimilarLocal(ZoneId zone)

将此日期时间与时区结合使用尝试保持相同的本地日期和时间创建ZonedDateTime.

4int compareTo(OffsetDateTime other)

比较此日期 - 到另一个日期时间的时间.

5boolean equals(Object obj)

检查此日期时间是否等于另一个日期-time.

6String format(DateTimeFormatter formatter)

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

7static OffsetDateTime from(TemporalAccessor temporal)

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

8int get(TemporalField field)

从中获取指定字段的值这个日期时间是一个int.

9int getDayOfMonth()

获取日期字段.

10DayOfWeek getDayOfWeek()

获取星期几字段,这是一个枚举DayOfWeek.

11int getDayOfYear()

获取年日字段.

12int getHour()

获取当日时间字段.

13long getLong(TemporalField field)

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

14Month getMinute()

获取分钟字段.

15Month getMonth()

获取使用该年份的月份字段月枚举.

16int getMonthValue()

获取1到12之间的年份字段.

17int getNano()

获取纳秒级字段.

18ZoneOffset getOffset()

获取区域偏移量,例如'+01:00'.

19int getSecond()

获取第二分钟字段.

20int getYear()

获取年份字段.

21int hashCode()

此日期时间的哈希码.

22boolean isAfter(OffsetDateTime other)

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

23boolean isBefore(OffsetDateTime other)

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

24boolean isEqual(OffsetDateTime other)

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

25boolean isSupported(TemporalField field)

检查指定的字段是否为suppor特德.

26boolean isSupported(TemporalUnit unit)

检查指定的单位是否受支持.

27OffsetDateTime minus(long amountToSubtract, TemporalUnit unit) 

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

28OffsetDateTime minus(TemporalAmount amountToSubtract)

返回此日期时间的副本,并减去指定的金额.

29OffsetDateTime minusDays(long daysToSubtract)

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

30OffsetDateTime minusHours(long hoursToSubtract)

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

31OffsetDateTime minusMinutes(long minutesToSubtract)

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

32OffsetDateTime minusMonths(long monthsToSubtract)

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

33OffsetDateTime minusNanos(long nanos)

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

34OffsetDateTime minusSeconds(long seconds)

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

35OffsetDateTime minusWeeks(long weeksToSubtract)

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

36OffsetDateTime minusYears(long yearsToSubtract)

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

37static OffsetDateTime now()

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

38static OffsetDateTime now(Clock clock)

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

39static OffsetDateTime now(ZoneId zone)

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

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

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

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

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

42static OffsetDateTime(LocalDateTime dateTime,ZoneOffset offset)

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

43static OffsetDateTime ofInstant(Instant instant, ZoneId zone)

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

44static OffsetDateTime parse(CharSequence text)

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

45static OffsetDateTime parse(CharSequence text,DateTimeFormatter formatter)

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

46OffsetDateTime plus(long amountToAdd,TemporalUnit unit) )

返回此日期时间的副本,并添加指定的金额.

47OffsetDateTime plus(TemporalAmount amountToAdd)

返回此日期时间的副本,并添加指定的金额.

48OffsetDateTime plusDays(long daysToAdd)

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

49OffsetDateTime plusHours(long hoursToAdd)

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

50OffsetDateTime plusMinutes(long minutesToAdd)

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

51OffsetDateTime plusMonths(long monthsToAdd)

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

52OffsetDateTime plusNanos(long nanos)

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

53OffsetDateTime plusSeconds(long seconds)

返回此OffsetDateTime的副本指定的秒数.

54OffsetDateTime plusWeeks(long weeksToAdd)

返回此OffsetDateTime的副本,其指定的数量为已添加周数.

55OffsetDateTime plusYears(long yearsToAdd)

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

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

使用指定的查询查询该日期时间.

57ValueRange range(TemporalField field)

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

58static Comparator<OffsetDateTime> timeLineOrder()

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

59long toEpochSecond()

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

60Instant toInstant( )

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

61LocalDate toLocalDate()

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

62LocalDateTime toLocalDateTime()

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

63LocalTime toLocalTime()

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

64OffsetTime toOffsetTime()

获取OffsetTime部分日期时间.

65String toString()

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

66ZonedDateTime toZonedDateTime()

将此日期时间转换为Zoned DateTime使用偏移量作为区域ID.

67OffsetDateTime truncatedTo(TemporalUnit unit)

返回此OffsetDateTime的副本与时间截断.

68long(Temporal endExclusive,TemporalUnit unit)

计算到达另一个日期时间的时间量指定的单位.

69OffsetDateTime with(TemporalAdjuster adjuster)

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

70OffsetDate时间(TemporalField字段,long newValue)

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

71OffsetDateTime withDayOfMonth(int dayOfMonth)

返回此OffsetDateTime的副本,其中每日更改日期.

72OffsetDateTime withDayOfYear(int dayOfYear)

返回此OffsetDateTime的副本,其中每年更改日期.

73OffsetDateTime withHour(int hour)

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

74OffsetDateTime withMinute(int minute)

返回此副本OffsetDateTime,每小时更改一次.

75OffsetDateTime withMonth(int month)

返回此OffsetDateTime的副本年度变更.

76OffsetDateTime withNano(int nanoOfSecond)

返回此OffsetDateTime的副本,其中包含nano-of - 第二次改变.

77OffsetDateTime withOffsetSameInstant(ZoneOffset offset)

返回此O的副本具有指定偏移量的ffsetDateTime确保结果在同一时刻.

78OffsetDateTime withOffsetSameLocal(ZoneOffset offset)

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

79OffsetDateTime withSecond(int second)

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

80OffsetDateTime withYear(int year)

返回a这个OffsetDateTime的副本,年份已更改.

Metho ds inherited

此类继承以下类中的方法 :

  • Java.lang.对象