ZoneOffsetTransition getOffsetAfter() method in Java with Example
Last Updated :
05 Jun, 2020
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:
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)
{
LocalDateTime loc
= LocalDateTime.of(
1999 , 04 , 25 , 03 ,
24 , 45 , 0 );
ZoneOffset off1
= ZoneOffset.ofTotalSeconds(
8 );
ZoneOffset off2
= ZoneOffset.ofTotalSeconds(
12 );
ZoneOffsetTransition zonetrans1
= ZoneOffsetTransition.of(
loc, off1, off2);
ZoneOffset off
= zonetrans1.getOffsetAfter();
System.out.println(
"Zoneoffset after transition : "
+ off);
}
}
|
Output:
Zoneoffset after transition : +00:00:12
Example 2:
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)
{
LocalDateTime loc
= LocalDateTime.of(
1999 , 04 , 25 , 03 ,
24 , 45 , 0 );
ZoneOffset off1
= ZoneOffset.ofTotalSeconds(
12 );
ZoneOffset off2
= ZoneOffset.ofTotalSeconds(
8 );
ZoneOffsetTransition zonetrans1
= ZoneOffsetTransition.of(
loc, off1, off2);
ZoneOffset off
= zonetrans1.getOffsetAfter();
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–
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...