java.time.LocalDateTime.getSecond() 方法示例



說明

java.time.LocalDateTime.getSecond() 方法獲取分鐘的秒欄位。

宣告

以下是 java.time.LocalDateTime.getSecond() 方法的宣告。

public int getSecond()

返回值

從 0 到 59 的分鐘秒。

示例

以下示例展示了 java.time.LocalDateTime.getSecond() 方法的用法。

package com.tutorialspoint;

import java.time.LocalDateTime;

public class LocalDateTimeDemo {
   public static void main(String[] args) {
 
      LocalDateTime date = LocalDateTime.parse("2017-02-03T12:30:30");
      System.out.println(date.getSecond());  
   }
}

讓我們編譯並執行以上程式,這會產生以下結果 −

30
廣告
© . All rights reserved.