java examples
Home Java Examples Resources Java Interview Questions
Brainpower SEO

How to get host's default timezone id?

package com.javacoderanch.example.util;

import java.util.TimeZone;

public class HostDefaultTimezone {
    public static void main(String[] args) {
        // Gets the default TimeZone ID for this host
        String id = TimeZone.getDefault().getID();
        System.out.println("nDefault Time Zone ID: " + id);

The default timezone id for this host is:

Default Time Zone ID: Asia/Shanghai