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



說明

java.time.OffsetTime.getSecond() 方法獲取分鐘秒數字段。

宣告

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

public int getSecond()

返回的值

分鐘秒數,取值範圍為 0 到 59。

示例

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

package com.tutorialspoint;

import java.time.OffsetTime;

public class OffsetTimeDemo {
   public static void main(String[] args) {
 
      OffsetTime time = OffsetTime.parse("12:30:30+01:00");
      System.out.println(time.getSecond());  
   }
}

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

30
廣告
© . All rights reserved.