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类