OffsetTime of(LocalTime) method in Java with Examples Last Updated : 05 Jun, 2020 Comments Improve Suggest changes Like Article Like Report The of(LocalTime time, ZoneOffset offset) method of the OffsetTime class in Java is used to create an instance of OffsetTime from the given instances of localtime and offset. Syntax: public static OffsetTime of(LocalTime time, ZoneOffset offset) Parameters: The method accepts two parameters. time - It represents the local time. It should not be null. offset - It represents the zone offset. It should not be null. Return value: This method returns the OffsetTime. Exception: This method does not throw any exception. Below programs illustrate the of(LocalTime, ZoneOffset) method of OffsetTime class in Java: Program 1: Java // Java program to demonstrate // OffsetTime of( // LocalTime, ZoneOffset) method import java.time.*; import java.time.temporal.*; public class GFG { public static void main( String[] args) { // Create OffsetTime object OffsetTime offsettime = OffsetTime.of( LocalTime.now(), ZoneOffset.UTC); // Print time System.out.println( "TIME: " + offsettime); } } Output: TIME: 03:14:11.212Z Program 2: Java // Java program to demonstrate // OffsetTime of( // LocalTime, ZoneOffset) method import java.time.*; import java.time.temporal.*; public class GFG { public static void main( String[] args) { // Create LocalTime object LocalTime time = LocalTime.of( 8, 45, 40, 50); // Create ZoneOffset object ZoneOffset offset = ZoneOffset.ofHoursMinutes( 5, 30); // Create OffsetTime object OffsetTime offsettime = OffsetTime.of( time, offset); // Print time System.out.println( "TIME: " + offsettime); } } Output: TIME: 08:45:40.000000050+05:30 References: https://docs.oracle.com/javase/10/docs/api/java/time/OffsetTime.html#of(java.time.LocalTime, java.time.ZoneOffset) Comment More infoAdvertise with us Next Article OffsetTime of(LocalTime) method in Java with Examples P pp_pankaj Follow Improve Article Tags : Java Java-Functions Java-OffsetTime Practice Tags : Java Similar Reads OffsetDateTime of(LocalDateTime) method in Java with Examples The of(LocalDateTime dateTime, ZoneOffset offset) method of the OffsetDateTime class in Java is used to create an instance of OffsetDateTime from given instances of date-time and offset. This method creates an OffsetDateTime with the specified local date-time and offset. Syntax: public static Offset 2 min read OffsetTime of() method in Java with Examples The of(int hour, int minute, int second, int nanosecond, ZoneOffset offset) method of the OffsetTime class in Java is used to create an instance of OffsetTime from the passed values of hour, minute, second and nanosecond. In this method, we pass the value of hour, minute, second and nanosecond in in 2 min read OffsetDateTime of(LocalDate, LocalTime) method in Java with Examples The of(LocalDate date, LocalTime time, ZoneOffset offset) method of the OffsetDateTime class in Java is used to create an instance of OffsetDateTime from given instances of date, time and offset. This method creates an OffsetDateTime with the specified local date, local time and offset. Syntax: publ 2 min read LocalTime ofInstant() method in Java with Examples The ofInstant() method of a LocalTime class is used to obtain an instance of LocalTime from an Instant and zone ID passed as parameters.In this method First, the offset from UTC/Greenwich is obtained using the zone ID and instant. Then, the local time has calculated from the instant and offset. Synt 2 min read LocalTime of() method in Java with Examples The of(int hour, int minute) method of the LocalTime class in Java is used to create an instance of LocalTime from the passed values of hour and minute. In this method, the hour and minute are passed in the Integer format and it returns time-based on these values. The values of second and nanosecond 4 min read OffsetTime now() method in Java with examples The now() method of OffsetTime class in Java obtains the current time from the system clock in the default time-zone. Syntax : public static OffsetTime now() Parameter: This method does not accepts any parameter. Return Value: It returns the current time using the system clock and default time-zone 2 min read OffsetDateTime of() method in Java with Examples The of(int year, int month, int day, int hour, int minute, int second, int nanosecond, ZoneOffset offset) method of the OffsetDateTime class in Java is used to create an instance of OffsetDateTime from the passed values of year, month, day, hour, minute, second, nanosecond and offset. In this method 3 min read LocalDateTime ofInstant() method in Java with Examples ofInstant(Instant instant, ZoneId zone) method of LocalDateTime class in Java is used to create an instance of LocalDateTime using an Instant and zone ID. These two parameters are passed to the method and method returns LocalDateTime on the basis of these two parameters. The calculation of the Local 2 min read LocalDateTime toLocalTime() method in Java with Examples The toLocalTime() method of LocalDateTime class is used to get the LocalTime representation of this LocalDateTime. This method is derived from the Object Class and behaves in the similar way. Syntax: public LocalTime toLocalTime() Parameter: This method takes no parameters. Returns: This method retu 1 min read LocalDate ofInstant() method in Java with Examples The ofInstant(Instant instant, ZoneId zone) method of LocalDate class in Java is used to create an instance of LocalDate from an Instant and zone ID. These two parameters are passed to the method and on the basis of those, an instance of LocalDate is created. The calculation of the LocalDate follows 2 min read Like