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