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



說明

java.time.ZonedDateTime.toLocalDate() 方法獲取此日期時間段的 LocalDate 部分。

宣告

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

public LocalDate toLocalDate()

返回值

此日期時間的日期部分(不能為空)。

示例

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

package com.tutorialspoint;

import java.time.ZonedDateTime;

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

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

2017-03-28
廣告