java.time.ZoneOffset.adjustInto(Temporal temporal)
方法调整指定时态对象以具有此ZoneOffset。
声明
以下是java.time.ZoneOffset.adjustInto(Temporal temporal)
方法的声明。
public Temporal adjustInto(Temporal temporal)
参数
temporal
- 要调整的目标对象,而不是null
。
返回值
调整后的对象,不为null
。
例外
DateTimeException
- 如果无法进行调整。ArithmeticException
- 如果发生数字溢出。
示例
以下示例显示了java.time.ZoneOffset.adjustInto(Temporal temporal)
方法的用法。
package com.zaixian;
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]
上一篇:
java.time.ZoneOffset类
下一篇:无