LocalTime atOffset(ZoneOffset offset) example

Description

LocalTime atOffset(ZoneOffset offset) combines this time with an offset to create an OffsetTime.

Syntax

atOffset has the following syntax.


public OffsetTime atOffset(ZoneOffset offset)

Example

The following example shows how to use atOffset.


import java.time.LocalTime;
import java.time.OffsetTime;
import java.time.ZoneOffset;
/*from w  w  w  .  j a  va  2s.c  o m*/
public class Main {
  public static void main(String[] args) {
    LocalTime l = LocalTime.now();
    OffsetTime t = l.atOffset(ZoneOffset.UTC);
    System.out.println(t);
  }
}

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