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(Locale locale) 

Source Link

Document

Returns a long standard time name of this TimeZone suitable for presentation to the user in the specified locale .

Usage

From source file:Main.java

public static void main(String args[]) {

    // create default time zone object
    TimeZone timezone = TimeZone.getTimeZone("Europe/Paris");

    // create locale
    Locale locale = new Locale("CHINESE", "CHINA");

    // get display name for specific locale
    String disname = timezone.getDisplayName(locale);

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

From source file:org.projectforge.web.wicket.converter.TimeZoneConverter.java

@Override
public String convertToString(final Object value, final Locale locale) {
    if (value == null) {
        return null;
    }//w ww. j  av a 2s  .  c  om
    final TimeZone timeZone = (TimeZone) value;
    return timeZone.getID() + " (" + timeZone.getDisplayName(locale) + ")";
}

From source file:com.jaspersoft.jasperserver.war.common.JdkTimeZonesList.java

protected String getTimeZoneDescription(TimeZone timeZone, Locale userLocale) {
    return timeZone.getDisplayName(userLocale);
}

From source file:org.shredzone.cilla.admin.TimeZoneBean.java

@PostConstruct
public void setup() {
    for (String id : TimeZone.getAvailableIDs()) {
        TimeZone tz = TimeZone.getTimeZone(id);
        timeZoneMap.put(id, tz);//from w  w  w .j  a va2s.c om
        timeZoneMap.put(tz.getDisplayName(Locale.ENGLISH).toLowerCase(), tz);
    }
}

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);/*from  w  ww. j  ava2  s.  c  o 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:com.jaspersoft.jasperserver.war.action.ReportDataSourceAction.java

public Event preparePropsForm(RequestContext context) throws Exception {
    ReportDataSourceWrapper formObject = (ReportDataSourceWrapper) getFormObject(context);
    ReportDataSource ds = formObject.getReportDataSource();

    Locale displayLocale = LocaleContextHolder.getLocale();
    String selectedTimezone = null;
    if (ds instanceof JdbcReportDataSource)
        selectedTimezone = ((JdbcReportDataSource) ds).getTimezone();
    if (ds instanceof JndiJdbcReportDataSource)
        selectedTimezone = ((JndiJdbcReportDataSource) ds).getTimezone();

    List timezoneList = timezones.getTimeZones(displayLocale);
    timezoneList = new ArrayList(timezoneList);
    if (selectedTimezone != null && selectedTimezone.length() > 0) {
        TimeZone zone = TimeZone.getTimeZone(selectedTimezone);
        StringOption option = new StringOption(selectedTimezone, zone.getDisplayName(displayLocale));
        if (!timezoneList.contains(option))
            timezoneList.add(0, option);
    }/*  w ww.  j  a v  a2s .  c o m*/
    context.getFlowScope().put("timezones", timezoneList);
    context.getFlowScope().put("selectedTimezone", selectedTimezone);

    // init report data source; set props to defaults if not present
    if (ds instanceof CustomReportDataSource) {
        CustomReportDataSource cds = (CustomReportDataSource) ds;
        // look up definition & use it to init defaults & set prop defs
        CustomDataSourceDefinition customDef = customDataSourceFactory.getDefinition(cds);
        customDef.setDefaultValues(cds);
        formObject.setCustomProperties(customDef.getEditablePropertyDefinitions());
        formObject.setCustomDatasourceLabel(customDef.getLabelName());
    }

    return success();
}

From source file:org.apache.logging.log4j.core.util.datetime.FastDateParserTest.java

@Test
public void testTzParses() throws Exception {
    // Check that all Locales can parse the time formats we use
    for (final Locale locale : Locale.getAvailableLocales()) {
        final FastDateParser fdp = new FastDateParser("yyyy/MM/dd z", TimeZone.getDefault(), locale);

        for (final TimeZone tz : new TimeZone[] { NEW_YORK, REYKJAVIK, GMT }) {
            final Calendar cal = Calendar.getInstance(tz, locale);
            cal.clear();//from   w  ww. ja  v a 2s .com
            cal.set(Calendar.YEAR, 2000);
            cal.set(Calendar.MONTH, 1);
            cal.set(Calendar.DAY_OF_MONTH, 10);
            final Date expected = cal.getTime();

            final Date actual = fdp.parse("2000/02/10 " + tz.getDisplayName(locale));
            Assert.assertEquals("tz:" + tz.getID() + " locale:" + locale.getDisplayName(), expected, actual);
        }
    }
}

From source file:com.jaspersoft.jasperserver.war.action.DataSourceAction.java

public Event initAction(RequestContext context) throws Exception {
    ReportDataSourceWrapper formObject = (ReportDataSourceWrapper) getFormObject(context);
    Object parentFlowObject = null;
    if (formObject != null) {
        parentFlowObject = formObject.getParentFlowObject();
    }/*  w ww .ja v  a2 s  .  com*/
    if (formObject.isNewMode()) {
        context.getFlowScope().put(TYPE, context.getExternalContext().getRequestParameterMap().get(TYPE));
    } else {
        context.getFlowScope().put(TYPE, getTypeByFormObjectByType(formObject.getType()));
    }

    String typeFromRequest = context.getExternalContext().getRequestParameterMap().get(TYPE);
    boolean forceNewMode = formObject.isSubflowMode();
    if (formObject.isNewMode() || typeFromRequest != null
            && !typeFromRequest.equals(getTypeByFormObjectByType(formObject.getType()))) {
        formObject = (ReportDataSourceWrapper) createFormObject(context);
        if (forceNewMode) {
            formObject.setParentFlowObject(parentFlowObject);
            formObject.setMode(BaseDTO.MODE_SUB_FLOW_NEW);
        }
    }

    ReportDataSource ds = formObject.getReportDataSource();

    Locale displayLocale = LocaleContextHolder.getLocale();
    String selectedTimezone = null;
    if (ds instanceof JdbcReportDataSource)
        selectedTimezone = ((JdbcReportDataSource) ds).getTimezone();
    if (ds instanceof JndiJdbcReportDataSource)
        selectedTimezone = ((JndiJdbcReportDataSource) ds).getTimezone();

    List timezoneList = timezones.getTimeZones(displayLocale);
    timezoneList = new ArrayList(timezoneList);
    if (selectedTimezone != null && selectedTimezone.length() > 0) {
        TimeZone zone = TimeZone.getTimeZone(selectedTimezone);
        StringOption option = new StringOption(selectedTimezone, zone.getDisplayName(displayLocale));
        if (!timezoneList.contains(option))
            timezoneList.add(0, option);
    }
    context.getFlowScope().put("timezones", timezoneList);
    context.getFlowScope().put("selectedTimezone", selectedTimezone);
    getFormObjectAccessor(context).setCurrentFormObject(formObject, ScopeType.FLOW);
    context.getFlowScope().put(FORM_OBJECT_KEY, formObject);
    context.getFlowScope().put(ATTRIBUTE_RESOURCE_ID_NOT_SUPPORTED_SYMBOLS,
            configuration.getResourceIdNotSupportedSymbols());
    context.getFlowScope().put("awsRegions", getAwsRegions());
    context.getFlowScope().put("isEc2Instance", awsEc2MetadataClient.isEc2Instance());
    context.getFlowScope().put("suppressEc2CredentialsWarnings",
            awsProperties.isSuppressEc2CredentialsWarnings());

    Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    if (principal != null && principal instanceof TenantQualified) {
        if (((TenantQualified) principal).getTenantId() != null) {
            context.getFlowScope().put("tenantId", ((TenantQualified) principal).getTenantId());
        }
    }

    String requestParentFolder = context.getExternalContext().getRequestParameterMap().get(PARENT_FOLDER_URI);
    if (formObject.getReportDataSource() != null) {
        if (isBlank(requestParentFolder) || !repository.repositoryPathExists(null, requestParentFolder)) {
            requestParentFolder = null;
        }
        formObject.getReportDataSource().setParentFolder(requestParentFolder);
    }

    if (formObject.isSubflowMode() && formObject.getAllDatasources() == null) {
        //   context.getFlowScope().put(FORM_OBJECT_KEY, formObject);
        context.getFlowScope().put("constants", constants);
        //return success();
    }

    if (ds instanceof CustomReportDataSource) {
        CustomReportDataSource cds = (CustomReportDataSource) ds;
        // look up definition & use it to init defaults & set prop defs
        CustomDataSourceDefinition customDef = customDataSourceFactory.getDefinition(cds);
        if (customDef != null) {
            customDef.setDefaultValues(cds);
            formObject.setCustomProperties(customDef.getEditablePropertyDefinitions());
            formObject.setCustomDatasourceLabel(customDef.getLabelName());
            context.getFlowScope().put(TYPE, customDef.getName());
        }
    }

    passwordSubstitution = messages.getMessage("input.password.substitution", null,
            LocaleContextHolder.getLocale());

    context.getFlowScope().put(JDBC_DRIVERS_JSON_KEY, JSONUtil.toJSON(getAvailableJdbcDrivers()));
    context.getFlowScope().put(DYNAMIC_URL_PART_PATTERN, JSONUtil.toJSON(this.dynamicUrlPartPattern));
    context.getFlowScope().put(VALIDATION_PATTERNS, JSONUtil.toJSON(this.validationPatternsMap));
    context.getFlowScope().put(PASSWORD_SUBSTITUTION_KEY, passwordSubstitution);

    return success();
}