Java OffsetTime class Java OffsetTime class is an immutable date-time object that represents a time, often viewed as hour-minute-second offset. It inherits Object class and implements the Comparable interface.
Java OffsetTime class declaration Let's see the declaration of java.time.OffsetTime class.
Methods of Java OffsetTime
Method |
Description |
String format(DateTimeFormatter formatter) |
It is used to format this time using the specified formatter. |
int get(TemporalField field) |
It is used to get the value of the specified field from this time as an int. |
int getHour() |
It is used to get the hour-of-day field. |
int getMinute() |
It is used to get the minute-of-hour field. |
int getSecond() |
It is used to get the second-of-minute field. |
static OffsetTime now() |
It is used to obtain the current time from the system clock in the default time-zone. |
static OffsetTime of(LocalTime time, ZoneOffset offset) |
It is used to obtain an instance of OffsetTime from a local time and an offset. |
ValueRange range(TemporalField field) |
It is used to get the range of valid values for the specified field. |
VLocalTime toLocalTime() |
It is used to get the LocalTime part of this date-time. |
Java OffsetTime class Example
Test it Now Output:
Java OffsetTime class Example: getHour()
Test it Now Output:
Java OffsetTime class Example: getMinute()
Test it Now Output:
Java OffsetTime class Example: getSecond()
Test it Now Output:
|