Example usage for java.util TimeZone getID

List of usage examples for java.util TimeZone getID

Introduction

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

Prototype

public String getID() 

Source Link

Document

Gets the ID of this time zone.

Usage

From source file:jp.classmethod.aws.brian.utils.GsonFactoryBean.java

@Override
public JsonElement serialize(TimeZone src, Type typeOfSrc, JsonSerializationContext context) {
    return new JsonPrimitive(src.getID());
}

From source file:org.eclipse.gyrex.admin.ui.jobs.internal.TimeZoneProposals.java

@Override
public IContentProposal[] getProposals(final String contents, final int position) {
    final List<IContentProposal> resultList = new ArrayList<IContentProposal>();

    final String patternString = StringUtils.trimToNull(StringUtils.substring(contents, 0, position));

    final String[] availableIDs = TimeZone.getAvailableIDs();
    Arrays.sort(availableIDs);//  w  w  w  .  j  a va2s.co  m
    for (final String id : availableIDs) {
        final TimeZone timeZone = TimeZone.getTimeZone(id);
        if ((null == patternString) || StringUtils.contains(StringUtils.lowerCase(timeZone.getID()),
                StringUtils.lowerCase(patternString))) {
            resultList.add(
                    new ContentProposal(timeZone.getID(), id + " - " + timeZone.getDisplayName(Locale.US)));
        }
    }

    return resultList.toArray(new IContentProposal[resultList.size()]);
}

From source file:org.nuxeo.ecm.user.center.profile.TimeZones.java

public String displayCurrentTimeZone() {
    TimeZoneSelector tzs = TimeZoneSelector.instance();
    String timeZoneId = tzs.getTimeZoneId();
    if (StringUtils.isEmpty(timeZoneId)) {
        TimeZone timeZone = tzs.getTimeZone();
        if (timeZone != null) {
            timeZoneId = timeZone.getID();
        }/*from  w w  w  .  j  a v a 2 s.  c o  m*/
    }
    return displayTimeZone(timeZoneId);
}

From source file:com.enonic.cms.core.user.field.UserFieldHelper.java

private String formatTimezone(TimeZone value) {
    return value.getID();
}

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

/**
 * @return long string representation of the given time zone
 *//*from   w  ww  .  jav  a2 s.c  o  m*/
public String getDisplayNameLong(@Nullable TimeZone timeZone) {
    if (timeZone == null)
        return "";
    String name = timeZone.getID();
    if (AD_HOC_TZ_PATTERN.matcher(name).matches())
        return name;
    else
        return name + " (" + getDisplayOffset(timeZone) + ")";
}

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

/**
 * {@inheritDoc}//from  ww  w . jav  a  2  s.  co  m
 */
@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());
    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.mtt.myapp.home.controller.HomeController.java

/**
 * Initialize {@link HomeController}./* w  w  w.ja va  2  s .c  o m*/
 */
@PostConstruct
public void init() {
    timeZones = new ArrayList<TimeZone>();
    final String[] timeZoneIds = TimeZone.getAvailableIDs();
    for (final String id : timeZoneIds) {
        if (id.matches(TIMEZONE_ID_PREFIXES) && !TimeZone.getTimeZone(id).getDisplayName().contains("GMT")) {
            timeZones.add(TimeZone.getTimeZone(id));
        }
    }
    Collections.sort(timeZones, new Comparator<TimeZone>() {
        public int compare(final TimeZone a, final TimeZone b) {
            return a.getID().compareTo(b.getID());
        }
    });
    scheduledTaskService.runAsync(new Runnable() {
        @Override
        public void run() {
            getLeftPanelEntries();
            getRightPanelEntries();
        }
    });
}

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());
    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();
}

From source file:org.crazydog.util.spring.StringUtils.java

/**
 * Parse the given {@code timeZoneString} value into a {@link TimeZone}.
 * @param timeZoneString the time zone {@code String}, following {@link TimeZone#getTimeZone(String)}
 * but throwing {@link IllegalArgumentException} in case of an invalid time zone specification
 * @return a corresponding {@link TimeZone} instance
 * @throws IllegalArgumentException in case of an invalid time zone specification
 *//*www .j a  va  2  s.  com*/
public static TimeZone parseTimeZoneString(String timeZoneString) {
    TimeZone timeZone = TimeZone.getTimeZone(timeZoneString);
    if ("GMT".equals(timeZone.getID()) && !timeZoneString.startsWith("GMT")) {
        // We don't want that GMT fallback...
        throw new IllegalArgumentException("Invalid time zone specification '" + timeZoneString + "'");
    }
    return timeZone;
}