OffsetDateTime getSecond() method in Java with examples
The getSecond() method of OffsetDateTime class in Java is used to get the value of the second-of-minute field.
Syntax :
public int getSecond()
Parameter : This method accepts does not accepts any parameter.
Return Value: It returns the second-of-minute which ranges from 0 to 59.
Below programs illustrate the getSecond() method:
Program 1 :
import java.time.OffsetDateTime;
public class GFG {
public static void main(String[] args)
{
OffsetDateTime date = OffsetDateTime.parse( "2018-12-03T12:30:30+01:00" );
System.out.println( "second: " + date.getSecond());
}
}
|
Program 2 :
import java.time.OffsetDateTime;
public class GFG {
public static void main(String[] args)
{
OffsetDateTime date = OffsetDateTime.parse( "2016-10-03T12:30:30+01:20" );
System.out.println( "second: " + date.getSecond());
}
}
|
Reference: https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html#getSecond–
Last Updated :
31 Oct, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...