java.time.ZonedDateTime.toOffsetDateTime()
方法将此日期时间转换为OffsetDateTime
。
声明
以下是java.time.ZonedDateTime.toOffsetDateTime()
方法的声明。
public OffsetDateTime toOffsetDateTime()
返回值
偏移日期时间,表示相同的本地日期时间和偏移量,不为null
。
示例
以下示例显示了java.time.ZonedDateTime.toOffsetDateTime()
方法的用法。
package com.yiibai;
import java.time.ZonedDateTime;
public class ZonedDateTimeDemo {
public static void main(String[] args) {
ZonedDateTime date = ZonedDateTime.now();
System.out.println(date.toOffsetDateTime());
}
}
编译并运行上面的程序,这将产生以下结果 -
2017-03-28T15:45:22.794+05:30