ZoneOffsetTransition toString() method in Java with Example Last Updated : 29 May, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The toString() method of java.time.zone.ZoneOffsetTransition class is used to get the string representation of this particular zone offset transition object. Syntax: public String toString() Parameter: This method does not accept any parameter. Return Value: This method returns the string representation of this particular zone offset transition. Below are the examples to illustrate the toString() method: Example 1: Java // Java program to demonstrate // toString() 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 string representation // of this object // by using toString() method String str = zonetrans1.toString(); // display the result System.out.println( "zone offset transition : " + str); } } Output: zone offset transition : Transition[Overlap at 1999-04-25T03:24:45+00:00:12 to +00:00:08] Example 2: Java // Java program to demonstrate // toString() 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(45); // creating and initializing // the object of ZoneOffset ZoneOffset off2 = ZoneOffset.ofTotalSeconds(20); // creating and initializing // ZoneOffsetTransition Object ZoneOffsetTransition zonetrans1 = ZoneOffsetTransition.of( loc, off1, off2); // getting the string representation // of this object // by using toString() method String str = zonetrans1.toString(); // display the result System.out.println( "zone offset transition : " + str); } } Output: zone offset transition : Transition[Overlap at 1999-04-25T03:24:45+00:00:45 to +00:00:20] Reference: https://docs.oracle.com/javase/9/docs/api/java/time/zone/ZoneOffsetTransition.html#toString-- Comment More infoAdvertise with us Next Article ZoneOffsetTransition toString() method in Java with Example R rohitprasad3 Follow Improve Article Tags : Java Java-Functions Practice Tags : Java Similar Reads ZoneOffset toString() method in Java with Examples The toString() method of ZoneOffset Class in java.time package is used to obtain String representation of this instance of ZoneOffset. This method does not takes any parameter and returns an String value. which is the String representation. Syntax: public static String toString() Parameters: This me 1 min read ZoneOffset of(String) method in Java with Examples The of(String) method of ZoneOffset Class in java.time package is used to obtain an instance of ZoneOffset using the offsetId passed as the parameter. This method takes the offsetId as parameter in the form of String and converts it into the ZoneOffset. The ID of the returned offset will be normaliz 2 min read ZoneId toString() method in Java with Examples The toString() method of the ZoneId class in Java is used to return this zone as a String, using the ID. Syntax: public String toString() Parameters: This method does not accepts any parameters. Return Value: This method returns a string representation of this time-zone ID. Below programs illustrate 1 min read ZonedDateTime toString() method in Java with Examples The toString() method of a ZonedDateTime class is used to return this ZonedDateTime as a String. The string consists of the LocalDateTime followed by the ZoneOffset. If the ZoneId is not the same as the offset, then the ID is output. Syntax: public String toString() Parameters: This method does not 1 min read Year toString() method in Java with Examples The toString() method of Year class in Java is used to return the string representation of this Year object. Syntax: public String toString() Parameter: This method does not accepts any parameter. Return Value: It returns the string representation of this Year object. Below programs illustrate the t 1 min read Like