Thursday, July 9, 2026
HomeLanguagesJavaSimpleTimeZone toString() method in Java with Examples

SimpleTimeZone toString() method in Java with Examples

The toString() method of SimpleTimeZone class is used to get a string representation of this time zone.

Syntax:

public String toString()

Parameters: The function does not accepts any parameter.

Return Value: The method has no return value.

Exception: The function does not throws any exception.

Program below demonstrates the above mentioned function:

Program 1:




// program to demonstrate the
// function java.util.SimpleTimeZone.toString()
import java.util.*;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // create simple time zone object
        SimpleTimeZone obj
            = new SimpleTimeZone(700, "US");
  
        // get string value of time zone
        // and print the result
        System.out.println("String value is = "
                           + obj.toString());
    }
}


Output:

String value is =  java.util.SimpleTimeZone[
    id=US,
    offset=700,
    dstSavings=3600000,
    useDaylight=false,
    startYear=0,
    startMode=0,
    startMonth=0,
    startDay=0,
    startDayOfWeek=0,
    startTime=0,
    startTimeMode=0,
    endMode=0,
    endMonth=0,
    endDay=0,
    endDayOfWeek=0,
    endTime=0,
    endTimeMode=0]

Program 2:




// program to demonstrate the
// function java.util.SimpleTimeZone.toString()
import java.util.*;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // create simple time zone object
        SimpleTimeZone obj
            = new SimpleTimeZone(800, "US");
  
        // get string value of time zone
        // and print the result
        System.out.println("String value is = "
                           + obj.toString());
    }
}


Output:

String value is =  java.util.SimpleTimeZone[
    id=US,
    offset=800,
    dstSavings=3600000,
    useDaylight=false,
    startYear=0,
    startMode=0,
    startMonth=0,
    startDay=0,
    startDayOfWeek=0,
    startTime=0,
    startTimeMode=0,
    endMode=0,
    endMonth=0,
    endDay=0,
    endDayOfWeek=0,
    endTime=0,
    endTimeMode=0]
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32519 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6901 POSTS0 COMMENTS
Nicole Veronica
12017 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12111 POSTS0 COMMENTS
Shaida Kate Naidoo
7020 POSTS0 COMMENTS
Ted Musemwa
7263 POSTS0 COMMENTS
Thapelo Manthata
6978 POSTS0 COMMENTS
Umr Jansen
6968 POSTS0 COMMENTS