Example usage for java.util TimeZone getDisplayName

List of usage examples for java.util TimeZone getDisplayName

Introduction

In this page you can find the example usage for java.util TimeZone getDisplayName.

Prototype

public final String getDisplayName(boolean daylight, int style) 

Source Link

Document

Returns a name in the specified style of this TimeZone suitable for presentation to the user in the default locale.

Usage

From source file:Main.java

public static void main(String args[]) {

    // create default time zone object
    TimeZone timezonedefault = TimeZone.getDefault();

    // get display name
    String disname = timezonedefault.getDisplayName(true, TimeZone.LONG);

    // checking display name         
    System.out.println("Display name is :" + disname);
}

From source file:Main.java

public static void main(String args[]) {

    // create default time zone object
    TimeZone timezonedefault = TimeZone.getDefault();

    // get display name
    String disname = timezonedefault.getDisplayName(true, TimeZone.SHORT);

    // checking display name         
    System.out.println("Display name is :" + disname);
}

From source file:Main.java

/**
 * @NAME getSimpleTZTag<br>// www.  j av  a2 s.  c o  m
 *   getSimpleTZTag
 */
public static String getSimpleTZTag() {
    try {
        TimeZone tz = TimeZone.getDefault();
        String s = "tz." + tz.getDisplayName(false, TimeZone.SHORT) + "tzid." + tz.getID();

        return s;
    } catch (Exception e) {
        return "";
    }
}

From source file:Main.java

/**
 * Produce a string describing the offset of the given time zone from
 * UTC, including the DST offset if there is one.
 * //from   w w  w  . j  a  v a  2s.  c  om
 * @param   zone         TimeZone whose offset we want.
 * @return               Formatted offset.
 */
public static String formatOffsetFull(TimeZone zone) {
    String fmt = zone.getID() + ": ";

    int base = zone.getRawOffset();
    fmt += zone.getDisplayName(false, TimeZone.LONG) + "=UTC" + intervalMsToHmsShort(base);

    int dst = zone.getDSTSavings();
    if (dst != 0)
        fmt += " (" + zone.getDisplayName(true, TimeZone.LONG) + "=UTC" + intervalMsToHmsShort(base + dst)
                + ")";

    return fmt;
}

From source file:org.apache.accumulo.monitor.servlets.DefaultServlet.java

/**
 * Shows the current time zone (based on the current time) short name
 *///ww  w  . j  a v  a  2s .com
private static String getShortTZName() {
    TimeZone tz = TimeZone.getDefault();
    return tz.getDisplayName(tz.inDaylightTime(new Date()), TimeZone.SHORT);
}

From source file:org.apache.oozie.servlet.BaseAdminServlet.java

@SuppressWarnings({ "unchecked", "rawtypes" })
private static void prepareGMTOffsetTimeZones() {
    for (String tzId : new String[] { "GMT-12:00", "GMT-11:00", "GMT-10:00", "GMT-09:00", "GMT-08:00",
            "GMT-07:00", "GMT-06:00", "GMT-05:00", "GMT-04:00", "GMT-03:00", "GMT-02:00", "GMT-01:00",
            "GMT+01:00", "GMT+02:00", "GMT+03:00", "GMT+04:00", "GMT+05:00", "GMT+06:00", "GMT+07:00",
            "GMT+08:00", "GMT+09:00", "GMT+10:00", "GMT+11:00", "GMT+12:00" }) {
        TimeZone tz = TimeZone.getTimeZone(tzId);
        JSONObject json = new JSONObject();
        json.put(JsonTags.TIME_ZOME_DISPLAY_NAME, tz.getDisplayName(false, TimeZone.SHORT) + " (" + tzId + ")");
        json.put(JsonTags.TIME_ZONE_ID, tzId);
        GMTOffsetTimeZones.add(json);/*from w w  w. jav  a2 s  .co  m*/
    }
}

From source file:org.openhab.binding.astro.internal.config.AstroThingConfig.java

/**
 * {@inheritDoc}//from  www .j a v a 2s  . c  om
 */
@Override
public String toString() {
    TimeZone tz = TimeZone.getDefault();
    StringBuilder tzInfo = new StringBuilder();
    tzInfo.append(tz.getID());
    tzInfo.append(" (").append(tz.getDisplayName(false, TimeZone.SHORT)).append(" ")
            .append(new SimpleDateFormat("Z").format(Calendar.getInstance().getTime()));
    tzInfo.append(")");
    return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("thing", thingUid)
            .append("geolocation", geolocation).append("interval", interval)
            .append("systemTimezone", tzInfo.toString())
            .append("daylightSavings", Calendar.getInstance().get(Calendar.DST_OFFSET) != 0).toString();
}

From source file:org.eclipse.smarthome.binding.astro.internal.config.AstroThingConfig.java

@Override
public String toString() {
    TimeZone tz = TimeZone.getDefault();
    StringBuilder tzInfo = new StringBuilder();
    tzInfo.append(tz.getID());// w w  w  .j  av a  2s  . com
    tzInfo.append(" (").append(tz.getDisplayName(false, TimeZone.SHORT)).append(" ")
            .append(new SimpleDateFormat("Z").format(Calendar.getInstance().getTime()));
    tzInfo.append(")");
    return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("thing", thingUid)
            .append("geolocation", geolocation).append("altitude", altitude).append("interval", interval)
            .append("systemTimezone", tzInfo.toString())
            .append("daylightSavings", Calendar.getInstance().get(Calendar.DST_OFFSET) != 0).toString();
}

From source file:com.haulmont.cuba.core.global.TimeZones.java

/**
 * @return short string representation of the given time zone
 *///from www .ja v  a2 s .  c o m
public String getDisplayNameShort(@Nullable TimeZone timeZone) {
    if (timeZone == null)
        return "";

    boolean dst = timeZone.inDaylightTime(timeSource.currentTimestamp());
    String name = timeZone.getDisplayName(dst, TimeZone.SHORT);

    if (AD_HOC_TZ_PATTERN.matcher(name).matches())
        return name;
    else
        return name + " (" + getDisplayOffset(timeZone) + ")";
}

From source file:org.openhab.binding.astro.internal.common.AstroConfig.java

@Override
public String toString() {
    String intervallMessage = (interval == 0 ? "disabled" : String.valueOf(interval));

    TimeZone tz = TimeZone.getDefault();
    StringBuilder tzInfo = new StringBuilder();
    tzInfo.append(tz.getID());/*from w w  w  .j  a  v a 2s  .  c om*/
    tzInfo.append(" (").append(tz.getDisplayName(false, TimeZone.SHORT)).append(" ")
            .append(new SimpleDateFormat("Z").format(Calendar.getInstance().getTime()));
    tzInfo.append(")");
    return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("latitude", latitude)
            .append("longitude", longitude).append("interval", intervallMessage)
            .append("systemTimezone", tzInfo.toString())
            .append("daylightSavings", Calendar.getInstance().get(Calendar.DST_OFFSET) != 0).toString();
}