Wednesday, 19 December 2018

How to use getDisplayName(boolean daylight, int style) method of java.util.TimeZone class


Click here to watch on Youtube:
https://www.youtube.com/watch?v=OgFJKm9T-is&list=UUhwKlOVR041tngjerWxVccw

TimeZoneDemo.java

import java.util.TimeZone;

public class TimeZoneDemo
{
    public static void main(String[] args)
    {
        TimeZone timezonedefault = TimeZone.getDefault();

        /*
         * Parameters:
         *
         * daylight - true specifying a Daylight Saving Time name, or
         * false specifying a Standard Time
         *
         * namestyle - either LONG or SHORTReturns:the human-readable
         * name of this time zone in the default locale.
         *
         * Returns:
         *
         * the human-readable name of this time zone in the default
         * locale.
         */

        String displayName = timezonedefault.getDisplayName(true,
                TimeZone.LONG);
        System.out.println("displayName LONG  = " + displayName);

        displayName = timezonedefault.getDisplayName(true, TimeZone.SHORT);
        System.out.println("displayName SHORT = " + displayName);
    }
}

Output

displayName LONG  = India Daylight Time
displayName SHORT = IDT

Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/TimeZoneDemo_getDisplayName_DL_Style.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/5bada39e8532ab4b75aaa28b80cdcee21bf19ab7/BasicJava_2018/TimeZoneDemo_getDisplayName_DL_Style/?at=master

See also:
  • All JavaEE Videos Playlist
  • All JavaEE Videos
  • All JAVA EE Links
  • Spring Tutorial
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • Cooking Tutorial
  • No comments:

    Post a comment