当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Java java.time.OffsetDateTime.toZonedDateTime()用法及代码示例



描述

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

声明

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

public ZonedDateTime toZonedDateTime()

返回值

一个 OffsetTime 表示时间和偏移量,不为空。

示例

下面的例子展示了 java.time.OffsetDateTime.toZonedDateTime() 方法的用法。

package com.tutorialspoint;

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.toZonedDateTime() Method Example。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。