Friday, January 30, 2026
HomeLanguagesJavaSimpleTimeZone hashCode() method in Java with Examples

SimpleTimeZone hashCode() method in Java with Examples

The hashCode() method of SimpleTimeZone class generates the hash code for the SimpleDateFormat object.

Syntax:

public int hashCode()

Parameters: The function does not accepts any parameters.

Return Value: It returns the hash code for this object.

Exception: The function does not throws any exceptions.

Program below demonstrates the above mentioned function:

Program 1:




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


Output:

SimpleTimeZone: java.util.SimpleTimeZone
[ 
 id=US,
 offset=500,
 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
]
Hash code is = 500

Program 2:




// program to demonstrate the
// function java.util.SimpleTimeZone.hashCode()
  
import java.util.*;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // create simple time zone object
        SimpleTimeZone obj
            = new SimpleTimeZone(500, "IN");
  
        System.out.println("SimpleTimeZone: "
                           + obj);
  
        // get hash code value and print
        System.out.println("Hash code is = "
                           + obj.hashCode());
    }
}


Output:

SimpleTimeZone: java.util.SimpleTimeZone
[ 
 id=IN,
 offset=500,
 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
]
Hash code is = 500
RELATED ARTICLES

Most Popular

Dominic
32478 POSTS0 COMMENTS
Milvus
122 POSTS0 COMMENTS
Nango Kala
6849 POSTS0 COMMENTS
Nicole Veronica
11978 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12065 POSTS0 COMMENTS
Shaida Kate Naidoo
6987 POSTS0 COMMENTS
Ted Musemwa
7222 POSTS0 COMMENTS
Thapelo Manthata
6934 POSTS0 COMMENTS
Umr Jansen
6917 POSTS0 COMMENTS