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



說明

java.time.ZonedDateTime.toLocalTime() 方法獲取此日期時間的 LocalTime 部分。

宣告

以下是 java.time.ZonedDateTime.toLocalTime() 方法的宣告。

public LocalTime toLocalTime()

返回值

此日期時間的非空時間部分。

示例

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

package com.tutorialspoint;

import java.time.ZonedDateTime;

public class ZonedDateTimeDemo {
   public static void main(String[] args) {
 
      ZonedDateTime date = ZonedDateTime.now();
      System.out.println(date.toLocalTime());  
   }
}

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

15:35:54.222
廣告