Easy learning with example program codes

Java 8 OffsetTime class

The java.time.OffsetTime class is an immutable date-time object that represents a time, often viewed as hour-minute-second offset.

Java OffsetTime class methods

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.


package com.codesjava;
import java.time.OffsetTime;
import java.time.temporal.ChronoField;
public class TestExample {
	public static void main(String args[]){
		OffsetTime offset =;  
	    int hour = offset.get(ChronoField.HOUR_OF_DAY);  
	    int minute = offset.get(ChronoField.MINUTE_OF_DAY);  
	    int second = offset.get(ChronoField.SECOND_OF_DAY);  


Posted in Date   

Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki