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