java.time.ZonedDateTime类

简介

java.time.ZonedDateTime 类表示ISO-8601日历系统中具有时区的日期时间,例如2007 -12-03T10:15:30 + 01:00欧洲/巴黎.

类声明

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

public final class ZonedDateTime
   extends Object
      implements Temporal, ChronoZonedDateTime<LocalDate>, Serializable


类方法

Sr.No.方法&描述
1boolean equals(Object obj)

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

2String format(DateTimeFormatter formatter)

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

3static ZonedDateTime from(TemporalAccessor temporal)

从时态对象获得ZonedDateTime的实例.

4int get(TemporalField field)

从此dat获取指定字段的值e-time as int.

5int getDayOfMonth()

获取日期字段.

6DayOfWeek getDayOfWeek()

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

7int getDayOfYear()

获取年日字段.

8int getHour()

获取当日时间字段.

9long getLong(TemporalField field)

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

10Month getMinute()

获取分钟字段.

11Month getMonth()

使用Month enum获取年份字段.

12int getMonthValue()

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

13int getNano()

获取秒的秒数字段.

14ZoneOffset getOffset()

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

15int getSecond()

获取第二分钟字段.

16int getYear()

获取年份字段.

17ZoneId getZone()

获取时区,例如"Europe/Paris".

18int hashCode()

哈希公司de这个日期时间.

19boolean isSupported(TemporalField field)

检查指定的字段是否受支持.

20boolean isSupported(TemporalUnit unit)

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

21ZonedDateTime减去(long amountToSubtract,TemporalUnit unit)

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

22ZonedDateTime减去(TemporalAmount amountToSubtract)

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

23ZonedDateTime minusDays(long daysToSubtract)

返回a这个ZonedDateTime的副本减去指定的天数.

24ZonedDateTime minusHours(long hoursToSubtract)

返回此ZonedDateTime的副本减去指定的小时数.

25ZonedDateTime minusMinutes(long minutesToSubtract)

返回具有指定编号的ZonedDateTime的副本减去分钟数.

26ZonedDateTime minusMonths(long monthsToSubtract)

返回此ZonedDateTime的副本减去指定的月数.

27ZonedDateTime minusNanos(long nanos)

返回此ZonedDateTime的副本,其指定的数量为减去纳秒.

28ZonedDateTime minusSeconds(long seconds)

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

29ZonedDateTime minusWeeks(long weeksToSubtract )

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

30ZonedDateTime minusYears(long yearsToSubtract)

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

31static ZonedDateTime now()

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

32static ZonedDateTime now(Clock clock)

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

33static ZonedDateTime now(ZoneId zone)

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

34static ZonedDateTime(int year,int month,int dayOfMonth,int hour,int minute,int second,int nanoOfSecond,ZoneId zone)

从中获取ZonedDateTime的实例年,月,日,小时,分钟,秒,纳秒和时区.

35static ZonedDateTime of(LocalDate date, LocalTime time, ZoneId zone)

从日期和时间获得ZonedDateTime的实例.

36static ZonedDateTime of(LocalDateTime date, ZoneId zone)

从本地日期时间获得ZonedDateTime的实例.

37static ZonedDateTime ofInstant(Instant instant, ZoneId zone)

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

38static ZonedDateTime ofInstant(LocalDateTime localDateTime, ZoneOffset offset, ZoneId zone)

从通过组合本地日期时间和偏移量形成的瞬间获得ZonedDateTime的实例.

39static ZonedDateTime ofLocal(LocalDateTime localDateTime, ZoneId zone, ZoneOffset preferredOffset)

获得一个inst如果可能,使用首选偏移量从本地日期时间开始使用ZonedDateTime.

40static ZonedDateTime ofStrict(LocalDateTime localDateTime, ZoneOffset offset, ZoneId zone)

获得ZonedDateTime的实例,严格验证本地日期时间,偏移量和区域ID的组合.

41static ZonedDateTime parse(CharSequence text)

从文本字符串中获取ZonedDateTime的实例,例如2007-12-03T10:15:30 + 01:00 [欧洲/巴黎].

42static ZonedDateTime parse(CharSequence text,DateTimeFormatter formatter)

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

43ZonedDateTime plus(long amountToAdd,TemporalUnit unit)

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

44ZonedDateTime plus(TemporalAmount amountToAdd)

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

45ZonedDateTime plusDays(long daysToAdd)

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

46ZonedDateTime plusHours(long hoursToAdd)

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

47ZonedDateTime plusMinutes(long minutesToAdd)

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

48ZonedDateTime plusMonths( long monthsToAdd)

返回此ZonedDateTime的副本,并添加指定的月数.

49ZonedDateTime plusNanos(long nanos)

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

50ZonedDateTime plusSeconds(long seconds)

返回此ZonedDateTime的副本,并添加指定的秒数.

51ZonedDateTime plusWeeks(long weeksToAdd)

返回此ZonedDateTime的副本,并添加指定的周数.

52ZonedDateTime plusYears(long yearsToAdd)

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

53<R> R query(TemporalQuery<R> query)

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

54ValueRange range(TemporalField field)

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

55LocalDate toLocalDate()

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

56LocalTime toLocalTime()

获取此日期的LocalTime部分-time.

57OffsetDateTime toOffsetDateTime()

Con将此日期时间转换为OffsetDateTime.

58String toString()

将此日期输出为字符串,例如2007- 12-03T10:15:30 + 01:00 [欧洲/巴黎].

59ZonedDateTime truncatedTo(TemporalUnit unit)

返回截断时间的ZonedDateTime的副本.

60long until(Temporal endExclusive, TemporalUnit unit)

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

61Zoned DateTime with(TemporalAdjuster adjuster)

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

62ZonedDateTime with(TemporalField field,long newValue) )

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

63ZonedDateTime withDayOfMonth(int dayOfMonth )

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

64ZonedDateTime withDayOfYear(int dayOfYear)

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

65ZonedDateTime withEarlierOffsetAtOverlap()

返回此日期时间的副本,将区域偏移更改为本地时间线重叠处的两个有效偏移中较早的一个。

66ZonedDateTime withFixedOffsetZone()

使用区域返回此日期时间的副本ID设置为偏移量.

67ZonedDateTime withHour(int hour)

返回此ZonedDateTime的副本,其小时为日改变.

68ZonedDateTime withLaterOffsetAtOverlap ()

返回此日期时间的副本,将区域偏移更改为本地时间线重叠处的两个有效偏移中的较晚者.

69ZonedDateTime withMinute(int minute)

返回此ZonedDateTime的副本,其中每小时更改一次.

70ZonedDateTime withMonth(int month)

返回此ZonedDateTime的副本,其中月份已更改.

71ZonedDateTime withNano(int nanoOfSecond)

返回此ZonedDateTime的副本,其中纳秒修改.

72ZonedDateTime withSecond(int second)

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

73ZonedDateTime withYear(int year)

返回此ZonedDateTime的副本,其中年份已更改.

74ZonedDateTime withZoneSameInstant(ZoneId zone)

使用不同的时区返回此日期时间的副本,保留当前时间.

75ZonedDateTime withZoneSameLocal(ZoneId zone)

使用广告返回此日期时间的副本不一致的时区,如果可能的话,保留当地的日期时间.

继承的方法

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

  • Java.lang.Object