Related Articles

Related Articles

ZoneOffsetTransitionRule createTransition() method in Java with Example
  • Last Updated : 29 May, 2020

The createTransition() method of java.time.zone.ZoneOffsetTransitionRule class is used to
create the object of particular zone offset transition for particular year.

Syntax:

public ZoneOffsetTransition createTransition(int year)

Parameter: this method takes the integer value year for which transition instance have to be generated..

Return Value: This method returns the object of particular zone offset transition for particular year.

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



Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java program to demonstrate
// createTransition() 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
        // ZoneOffsetTransitionRule Object
        ZoneOffsetTransitionRule zonetrans1
            = ZoneOffsetTransitionRule
                  .of(
                      Month.JANUARY, 12,
                      DayOfWeek.SUNDAY,
                      LocalTime.of(03, 24, 45),
                      false,
                      ZoneOffsetTransitionRule
                          .TimeDefinition
                          .STANDARD,
                      ZoneOffset.ofTotalSeconds(8),
                      ZoneOffset.ofTotalSeconds(10),
                      ZoneOffset.ofTotalSeconds(12));
  
        // getting object of ZoneOffsetTransition
        // by using createTransition() method
        ZoneOffsetTransition zoo
            = zonetrans1.createTransition(10);
  
        // display the result
        System.out.println("ZoneOffsetTransition : "
                           + zoo);
    }
}

chevron_right


Output:

ZoneOffsetTransition : Transition[Gap at 0010-01-17T03:24:47+00:00:10 to +00:00:12]

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java program to demonstrate
// createTransition() 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
        // ZoneOffsetTransitionRule Object
        ZoneOffsetTransitionRule zonetrans1
            = ZoneOffsetTransitionRule
                  .of(
                      Month.JANUARY, 12,
                      DayOfWeek.SUNDAY,
                      LocalTime.of(03, 24, 45),
                      false,
                      ZoneOffsetTransitionRule
                          .TimeDefinition
                          .STANDARD,
                      ZoneOffset.ofTotalSeconds(8),
                      ZoneOffset.ofTotalSeconds(10),
                      ZoneOffset.ofTotalSeconds(12));
  
        // getting object of ZoneOffsetTransition
        // by using createTransition() method
        ZoneOffsetTransition zoo
            = zonetrans1.createTransition(14);
  
        // display the result
        System.out.println(
            "ZoneOffsetTransition : "
            + zoo);
    }
}

chevron_right


Output:

ZoneOffsetTransition : Transition[Gap at 0014-01-12T03:24:47+00:00:10 to +00:00:12]

Reference: https://docs.oracle.com/javase/9/docs/api/java/time/zone/ZoneOffsetTransitionRule.html#createTransition-int-

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.




My Personal Notes arrow_drop_up
Recommended Articles
Page :