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



说明

java.time.ZonedDateTime.isSupported(TemporalUnit unit) 方法检查指定单位是否受支持。

声明

以下是 java.time.ZonedDateTime.isSupported(TemporalUnit unit) 方法的声明。

public boolean isSupported(TemporalUnit unit)

参数

unit - 要检查的单位,如果为 null,则返回 false。

返回值

如果在此日期支持该单位,则返回 true;如果不支持,则返回 false。

示例

以下示例显示了 java.time.ZonedDateTime.isSupported(TemporalUnit unit) 方法的使用情况。

package com.tutorialspoint;

import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;

public class ZonedDateTimeDemo {
   public static void main(String[] args) {
 
      ZonedDateTime date = ZonedDateTime.parse("2017-03-28T12:25:38.492+05:30[Asia/Calcutta]");
      System.out.println(date.isSupported(ChronoUnit.DAYS));  
   }
}

让我们编译并运行上述程序,这将产生以下结果 -

true
广告
© . All rights reserved.