java.time.ZonedDateTime.toOffsetDateTime() 方法
描述
java.time.ZonedDateTime.toOffsetDateTime() 方法将此日期时间转换为 OffsetDateTime。
声明
以下是 java.time.ZonedDateTime.toOffsetDateTime() 方法的声明。
public OffsetDateTime toOffsetDateTime()
返回值
一个偏移日期时间,表示相同的本地日期时间和偏移量,不为空。
示例
下面的例子展示了 java.time.ZonedDateTime.toOffsetDateTime() 方法的使用。
package com.tutorialspoint;
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

