目录

ZonedDateTime toZonedDateTime()

描述 (Description)

java.time.OffsetDateTime.toZonedDateTime()方法使用offset作为区域ID将此日期时间转换为ZonedDateTime。

声明 (Declaration)

以下是java.time.OffsetDateTime.toZonedDateTime()方法的声明。

public ZonedDateTime toZonedDateTime()

返回值 (Return Value)

表示时间和偏移量的OffsetTime,不为null。

例子 (Example)

以下示例显示了java.time.OffsetDateTime.toZonedDateTime()方法的用法。

package com.iowiki;
import java.time.OffsetDateTime;
public class OffsetDateTimeDemo {
   public static void main(String[] args) {
      OffsetDateTime date = OffsetDateTime.now();
      System.out.println(date.toZonedDateTime());  
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

2017-03-21T14:35:55.111+05:30
↑回到顶部↑
WIKI教程 @2018