ZonedDateTime getOffset() example
Description
ZonedDateTime 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.ZonedDateTime;
/*from w ww . ja va 2 s . c om*/
public class Main {
public static void main(String[] args) {
ZonedDateTime dateTime =ZonedDateTime.now();
System.out.println(dateTime.getOffset());
}
}
The code above generates the following result.