java.time.OffsetDateTime toZonedDateTime()方法

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

1 语法

public ZonedDateTime toZonedDateTime()

2 参数

3 返回值

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

4 示例 

package com.yiidian;

/**
 * 一点教程网: http://www.yiidian.com
 */
/**
 * java.time.OffsetDateTime toZonedDateTime()方法
 */
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

 

热门文章

优秀文章