Java中OffsetTime类的getSecond()方法用于从此offsetTime实例获取second-of-minute字段的值。
用法:
public int getSecond()
参数:此方法接受不接受任何参数。
返回值:它返回second-of-minute,范围从0到59。
以下示例程序旨在说明getSecond()方法:
示例1:
// Java program to demonstrate the getSecond() method
import java.time.OffsetTime;
public class GFG {
public static void main(String[] args)
{
// Parses the time
OffsetTime time = OffsetTime.parse("15:10:30+07:00");
// gets the second in time
System.out.println("second: " + time.getSecond());
}
}
输出:
second: 30
输出:
second: 30
程序2:
// Java program to demonstrate the getSecond() method
import java.time.OffsetTime;
public class GFG {
public static void main(String[] args)
{
// Parses the time
OffsetTime time = OffsetTime.parse("11:30:50+06:00");
// gets the second in time
System.out.println("second: " + time.getSecond());
}
}
输出:
second: 50
参考: https://docs.oracle.com/javase/8/docs/api/java/time/OffsetTime.html#getSecond–
相关用法
- Java OffsetDateTime getSecond()用法及代码示例
- Java ZonedDateTime getSecond()用法及代码示例
- Java LocalTime getSecond()用法及代码示例
- Java LocalDateTime getSecond()用法及代码示例
- Java OffsetTime plus()用法及代码示例
- Java OffsetTime until()用法及代码示例
- Java OffsetTime with()用法及代码示例
- Java OffsetTime hashCode()用法及代码示例
- Java OffsetTime get()用法及代码示例
- Java OffsetTime now()用法及代码示例
- Java OffsetTime from()用法及代码示例
- Java OffsetTime minusSeconds()用法及代码示例
- Java OffsetTime plusNanos()用法及代码示例
- Java OffsetTime isEqual()用法及代码示例
- Java OffsetTime plusHours()用法及代码示例
注:本文由纯净天空筛选整理自gopaldave大神的英文原创作品 OffsetTime getSecond() in Java with examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。