Wednesday, July 8, 2026
HomeLanguagesJavaZoneOffsetTransition getOffsetAfter() method in Java with Example

ZoneOffsetTransition getOffsetAfter() method in Java with Example

The getOffsetAfter() method of java.time.zone.ZoneOffsetTransition class is used to get the offset value of second offset zone after transition has taken place. The first and second offset refers to the value passed while creating the ZoneOffsetTransition Object.

Syntax:

public ZoneOffset getOffsetAfter()

Parameter: This method does not accept any parameter.

Return Value: This method returns the offset value of the second zone offset after transition has taken place. It does not return Null.

Below are the examples to illustrate the getOffsetAfter() method:

Example 1:




// Java program to demonstrate
// getOffsetAfter() method
  
import java.util.*;
import java.io.*;
import java.time.*;
import java.time.chrono.*;
import java.time.zone.*;
  
public class GFG {
    public static void main(String[] argv)
    {
  
        // Creating and initializing the
        // object of LocalDateTime
        LocalDateTime loc
            = LocalDateTime.of(
                1999, 04, 25, 03,
                24, 45, 0);
  
        // Creating and initializing the
        // object of ZoneOffset
        ZoneOffset off1
            = ZoneOffset.ofTotalSeconds(
                8);
  
        // Creating and initializing the
        // object of ZoneOffset
        ZoneOffset off2
            = ZoneOffset.ofTotalSeconds(
                12);
  
        // Creating and initializing
        // ZoneOffsetTransition Object
        ZoneOffsetTransition zonetrans1
            = ZoneOffsetTransition.of(
                loc, off1, off2);
  
        // Getting the offset after value
        // by using getOffsetAfter() method
        ZoneOffset off
            = zonetrans1.getOffsetAfter();
  
        // Display the result
        System.out.println(
            "Zoneoffset after transition : "
            + off);
    }
}


Output:

Zoneoffset after transition : +00:00:12

Example 2:




// Java program to demonstrate
// getOffsetAfter() method
  
import java.util.*;
import java.io.*;
import java.time.*;
import java.time.chrono.*;
import java.time.zone.*;
  
public class GFG {
    public static void main(String[] argv)
    {
  
        // Creating and initializing the
        // object of LocalDateTime
        LocalDateTime loc
            = LocalDateTime.of(
                1999, 04, 25, 03,
                24, 45, 0);
  
        // Creating and initializing the
        // object of ZoneOffset
        ZoneOffset off1
            = ZoneOffset.ofTotalSeconds(
                12);
  
        // Creating and initializing the
        // object of ZoneOffset
        ZoneOffset off2
            = ZoneOffset.ofTotalSeconds(
                8);
  
        // Creating and initializing
        // ZoneOffsetTransition Object
        ZoneOffsetTransition zonetrans1
            = ZoneOffsetTransition.of(
                loc, off1, off2);
  
        // Getting the offset after value
        // by using getOffsetAfter() method
        ZoneOffset off
            = zonetrans1.getOffsetAfter();
  
        // Display the result
        System.out.println(
            "Zoneoffset after transition : "
            + off);
    }
}


Output:

Zoneoffset after transition : +00:00:08

Reference:https://docs.oracle.com/javase/9/docs/api/java/time/zone/ZoneOffsetTransition.html#getOffsetAfter–

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

2 COMMENTS

Most Popular

Dominic
32519 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6900 POSTS0 COMMENTS
Nicole Veronica
12016 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12110 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7263 POSTS0 COMMENTS
Thapelo Manthata
6977 POSTS0 COMMENTS
Umr Jansen
6968 POSTS0 COMMENTS