java.time.ZonedDateTime.toLocalTime()方法

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

聲明

以下是java.time.ZonedDateTime.toLocalTime()方法的聲明。

public LocalTime toLocalTime()

返回值

此日期時間的時間部分,不為null

示例

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

package com.zaixian;

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

上一篇: java.time.ZonedDateTime類 下一篇: java.time.ZoneId類