java.time.OffsetDateTime.toZonedDateTime()方法

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

声明

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

public ZonedDateTime toZonedDateTime()

返回值

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

示例

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

package com.zaixian;

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

上一篇: java.time.OffsetDateTime类 下一篇: java.time.OffsetTime类