- 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.ZoneOffset.adjustInto() 方法示例
说明
java.time.ZoneOffset.adjustInto(Temporal temporal) 方法调整指定的时间对象以具有这个区域偏移。
声明
以下是 java.time.ZoneOffset.adjustInto(Temporal temporal) 方法的声明。
public Temporal adjustInto(Temporal temporal)
参数
temporal - 要调整的目标对象(不为 null)。
返回值
调整后的对象(不为 null)。
异常
DateTimeException - 如果无法进行调整。
ArithmeticException - 如果出现数字溢出。
示例
以下示例演示了 java.time.ZoneOffset.adjustInto(Temporal temporal) 方法的使用。
package com.tutorialspoint;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
public class ZoneOffsetDemo {
public static void main(String[] args) {
ZonedDateTime date = ZonedDateTime.now();
System.out.println(date);
ZoneOffset zoneOffset = ZoneOffset.of("Z");
date = (ZonedDateTime)zoneOffset.adjustInto(date);
System.out.println(date);
}
}
让我们编译和运行上面的程序,这将生成以下结果 -
2017-03-30T10:27:47.118+05:30[Asia/Calcutta] 2017-03-30T10:27:47.118+05:30[Asia/Calcutta]
广告