Java Date Time - ZonedDateTime withFixedOffsetZone() example








ZonedDateTime withFixedOffsetZone() returns a copy of this date-time with the zone ID set to the offset.

Syntax

withFixedOffsetZone has the following syntax.

public ZonedDateTime withFixedOffsetZone()

Example

The following example shows how to use withFixedOffsetZone.

import java.time.ZonedDateTime;

public class Main {
  public static void main(String[] args) {
    ZonedDateTime dateTime =ZonedDateTime.now();
    ZonedDateTime l =dateTime.withFixedOffsetZone() ;
    System.out.println(l);
  } 
}

The code above generates the following result.