OffsetDateTime getOffset() example
Description
OffsetDateTime getOffset()
gets the zone offset,
such as '+01:00'.
This is the offset of the local date-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.OffsetDateTime;
import java.time.ZoneOffset;
/*from ww w .j ava 2 s. c o m*/
public class Main {
public static void main(String[] args) {
OffsetDateTime o = OffsetDateTime.now();
ZoneOffset l = o.getOffset();
System.out.println(l);
}
}
The code above generates the following result.