- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get the default Time Zone in Java
In order to get the default Time Zone in Java, we use the getDefault() method. The java.util.TimeZone.getDefault() method returns the default TimeZone for the particular host. The source of the default TimeZone varies with the implementation.
Declaration −The java.util.TimeZone.getDefault() method is declared as follows −
public static TimeZone getDefault()
Let us see a program to get the default time zone in Java −
Example
import java.util.*; public class Example { public static void main( String args[] ) { // creating default object of TimeZone TimeZone obj = TimeZone.getDefault(); System.out.println("Default timezone object:
" + obj); } }
Output
Default timezone object: sun.util.calendar.ZoneInfo[id="Etc/UTC",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]
Advertisements