OffsetTime of(LocalTime time, ZoneOffset offset) example

Description

OffsetTime of(LocalTime time, ZoneOffset offset) creates an instance of OffsetTime from a local time and an offset.

Syntax

of has the following syntax.


public static OffsetTime of(LocalTime time,   ZoneOffset offset)

Example

The following example shows how to use of.


import java.time.LocalTime;
import java.time.OffsetTime;
import java.time.ZoneOffset;
// w  w w.  j  a va 2 s .c  o m
public class Main {
  public static void main(String[] args) {
    OffsetTime m = OffsetTime.of(LocalTime.now(),ZoneOffset.UTC);

    System.out.println(m);

  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset