类的用途
java.time.OffsetDateTime
使用 OffsetDateTime 的包
-
OffsetDateTime 在 java.time 中的用法
java.time 中的字段声明为 OffsetDateTime修饰符和类型Field描述static final OffsetDateTimeOffsetDateTime.MAX最大支持OffsetDateTime,'+999999999-12-31T23:59:59.999999999-18:00'。static final OffsetDateTimeOffsetDateTime.MIN支持的最小值OffsetDateTime,'-999999999-01-01T00:00:00+18:00'。java.time 中返回 OffsetDateTime 的方法修饰符和类型方法描述将这个时间与日期结合起来创建一个OffsetDateTime。Instant.atOffset(ZoneOffset offset) 将这个瞬间与偏移量结合起来创建一个OffsetDateTime。LocalDateTime.atOffset(ZoneOffset offset) 将此日期时间与偏移量组合以创建OffsetDateTime。LocalDate.atTime(OffsetTime time) 将此日期与偏移时间组合以创建OffsetDateTime。static OffsetDateTimeOffsetDateTime.from(TemporalAccessor temporal) 从时间对象中获取OffsetDateTime的实例。OffsetDateTime.minus(long amountToSubtract, TemporalUnit unit) 返回此日期时间的副本,并减去指定的数量。OffsetDateTime.minus(TemporalAmount amountToSubtract) 返回此日期时间的副本,并减去指定的数量。OffsetDateTime.minusDays(long days) 返回此OffsetDateTime的副本,并减去指定的天数。OffsetDateTime.minusHours(long hours) 返回此OffsetDateTime的副本,并减去指定的小时数。OffsetDateTime.minusMinutes(long minutes) 返回此OffsetDateTime的副本,并减去指定的分钟数。OffsetDateTime.minusMonths(long months) 返回此OffsetDateTime的副本,并减去指定的月数。OffsetDateTime.minusNanos(long nanos) 返回此OffsetDateTime的副本,并减去指定的纳秒数。OffsetDateTime.minusSeconds(long seconds) 返回此OffsetDateTime的副本,并减去指定的秒数。OffsetDateTime.minusWeeks(long weeks) 返回此OffsetDateTime的副本,并减去指定的周数。OffsetDateTime.minusYears(long years) 返回此OffsetDateTime的副本,并减去指定的年数。static OffsetDateTimeOffsetDateTime.now()从默认时区的系统时钟获取当前日期时间。static OffsetDateTime从指定时钟获取当前日期时间。static OffsetDateTime从指定时区的系统时钟获取当前日期时间。static OffsetDateTimeOffsetDateTime.of(int year, int month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond, ZoneOffset offset) 从年、月、日、小时、分钟、秒、纳秒和偏移量中获取OffsetDateTime的实例。static OffsetDateTimeOffsetDateTime.of(LocalDate date, LocalTime time, ZoneOffset offset) 从日期、时间和偏移量中获取OffsetDateTime的实例。static OffsetDateTimeOffsetDateTime.of(LocalDateTime dateTime, ZoneOffset offset) 从日期时间和偏移量获取OffsetDateTime的实例。static OffsetDateTime从Instant和区域 ID 获取OffsetDateTime的实例。static OffsetDateTimeOffsetDateTime.parse(CharSequence text) 从2007-12-03T10:15:30+01:00等文本字符串中获取OffsetDateTime的实例。static OffsetDateTimeOffsetDateTime.parse(CharSequence text, DateTimeFormatter formatter) 使用特定格式化程序从文本字符串中获取OffsetDateTime的实例。OffsetDateTime.plus(long amountToAdd, TemporalUnit unit) 返回添加了指定数量的此日期时间的副本。OffsetDateTime.plus(TemporalAmount amountToAdd) 返回添加了指定数量的此日期时间的副本。OffsetDateTime.plusDays(long days) 返回此 OffsetDateTime 的副本,并添加了指定的天数。OffsetDateTime.plusHours(long hours) 返回此OffsetDateTime的副本,并添加了指定的小时数。OffsetDateTime.plusMinutes(long minutes) 返回此OffsetDateTime的副本,并添加了指定的分钟数。OffsetDateTime.plusMonths(long months) 返回此OffsetDateTime的副本,并添加了指定的月数。OffsetDateTime.plusNanos(long nanos) 返回此OffsetDateTime的副本,并添加了指定的纳秒数。OffsetDateTime.plusSeconds(long seconds) 返回此OffsetDateTime的副本,并添加了指定的秒数。OffsetDateTime.plusWeeks(long weeks) 返回此 OffsetDateTime 的副本,其中添加了指定的周数。OffsetDateTime.plusYears(long years) 返回此OffsetDateTime的副本,并添加了指定的年数。ZonedDateTime.toOffsetDateTime()将此日期时间转换为OffsetDateTime。OffsetDateTime.truncatedTo(TemporalUnit unit) 返回此OffsetDateTime的副本,时间被截断。OffsetDateTime.with(TemporalAdjuster adjuster) 返回此日期时间的调整副本。OffsetDateTime.with(TemporalField field, long newValue) 返回此日期时间的副本,并将指定字段设置为新值。OffsetDateTime.withDayOfMonth(int dayOfMonth) 返回此OffsetDateTime的副本,其中日期已更改。OffsetDateTime.withDayOfYear(int dayOfYear) 返回此OffsetDateTime的副本,其中日期已更改。OffsetDateTime.withHour(int hour) 返回此OffsetDateTime的副本,其中更改了一天中的小时数。OffsetDateTime.withMinute(int minute) 返回此OffsetDateTime的副本,并更改了分钟。OffsetDateTime.withMonth(int month) 返回此OffsetDateTime的副本,其中更改了月份。OffsetDateTime.withNano(int nanoOfSecond) 返回此OffsetDateTime的副本,并更改了纳秒级。OffsetDateTime.withOffsetSameInstant(ZoneOffset offset) 返回具有指定偏移量的此OffsetDateTime的副本,确保结果在同一时刻。OffsetDateTime.withOffsetSameLocal(ZoneOffset offset) 返回具有指定偏移量的此OffsetDateTime的副本,确保结果具有相同的本地日期时间。OffsetDateTime.withSecond(int second) 返回此OffsetDateTime的副本,并更改了秒数。OffsetDateTime.withYear(int year) 返回此OffsetDateTime的副本,并更改年份。返回类型中包含 OffsetDateTime 类型参数的 java.time 中的方法修饰符和类型方法描述static Comparator<OffsetDateTime>OffsetDateTime.timeLineOrder()获取一个比较器,该比较器仅基于瞬间比较两个OffsetDateTime实例。java.time 中的方法,参数类型为 OffsetDateTime修饰符和类型方法描述intOffsetDateTime.compareTo(OffsetDateTime other) 将此日期时间与另一个日期时间进行比较。booleanOffsetDateTime.isAfter(OffsetDateTime other) 检查此日期时间的时刻是否在指定日期时间的时刻之后。booleanOffsetDateTime.isBefore(OffsetDateTime other) 检查此日期时间的时刻是否早于指定日期时间的时刻。booleanOffsetDateTime.isEqual(OffsetDateTime other) 检查此日期时间的时刻是否等于指定日期时间的时刻。