OffsetTime getOffset() example

Description

OffsetTime getOffset() gets the zone offset, such as '+01:00'.

This is the offset of the local time from UTC/Greenwich.

Syntax

getOffset has the following syntax.


public ZoneOffset getOffset()

Example

The following example shows how to use getOffset.


import java.time.OffsetTime;
import java.time.ZoneOffset;
/*from  w  w w  . j a v a  2  s . c o m*/
public class Main {
  public static void main(String[] args) {
    OffsetTime m = OffsetTime.now();
    ZoneOffset z = m.getOffset();
    System.out.println(z);

  }
}

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