java.time.OffsetTime.toLocalTime() 方法示例



說明

java.time.OffsetTime.toLocalTime() 方法獲取此日期時間的本地時間部分。

申明

以下是 java.time.OffsetTime.toLocalTime() 方法的申明。

public LocalTime toLocalTime()

返回值

非 null,此日期時間的 time 部分。

示例

以下示例展示了 java.time.OffsetTime.toLocalTime() 方法的使用。

package com.tutorialspoint;

import java.time.OffsetTime;

public class OffsetTimeDemo {
   public static void main(String[] args) {
 
      OffsetTime time = OffsetTime.now();
      System.out.println(time.toLocalTime());  
   }
}

讓我們編譯並執行以上程式,這將產生以下結果 −

14:55:41.752
廣告
© . All rights reserved.