- java.time 包的类
- java.time - 主页
- java.time - 时钟
- java.time - 持续时间
- java.time - 时间
- java.time - 本地日期
- java.time - 本地时间
- java.time - 本地时间
- java.time - 月日
- java.time - 偏时日期
- java.time - 偏时时间
- java.time - 期
- java.time - 年
- java.time - 年月
- java.time - 区域时日期
- java.time - 时区 ID
- java.time - 时区偏移
- java.time 包枚举
- java.time - 月
- java.time 有用资源
- java.time - 讨论
java.time.OffsetDateTime.adjustInto() 方法示例
描述
java.time.OffsetDateTime.adjustInto(Temporal temporal) 方法调整指定的时间对象以具有与该对象相同的日期和时间。
声明
下面是 java.time.OffsetDateTime.adjustInto(Temporal temporal) 的声明。
public Temporal adjustInto(Temporal temporal)
参数
temporal - 要调整的目标对象,非 null。
返回值
调整后的对象,非 null。
异常
DateTimeException - 如果无法进行调整。
ArithmeticException - 如果发生数值溢出。
示例
以下示例演示了 java.time.OffsetDateTime.adjustInto(Temporal temporal) 方法的用法。
package com.tutorialspoint;
import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
public class OffsetDateTimeDemo {
public static void main(String[] args) {
ZonedDateTime date = ZonedDateTime.now();
System.out.println(date);
OffsetDateTime date1 = OffsetDateTime.parse("2017-02-03T12:30:30+01:00");
date = (ZonedDateTime)date1.adjustInto(date);
System.out.println(date);
}
}
让我们编译并运行上述程序,这会产生以下结果 -
2017-03-21T12:07:31.334+05:30[Asia/Calcutta] 2017-02-03T12:30:30+05:30[Asia/Calcutta]
广告