Example usage for java.util Locale equals

List of usage examples for java.util Locale equals

Introduction

In this page you can find the example usage for java.util Locale equals.

Prototype

@Override
public boolean equals(Object obj) 

Source Link

Document

Returns true if this Locale is equal to another object.

Usage

From source file:Main.java

public DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale locale) {
    if (locale.equals(ca)) {
        return new SimpleDateFormat("yyyy/MM/dd");
    }/*from  w  ww  .  j a v  a 2s .c o m*/
    return null;
}

From source file:Main.java

@Override
public DateFormat getDateInstance(int style, Locale locale) {
    if (locale.equals(ca)) {
        return new SimpleDateFormat("MM/dd");
    }//from w  ww .  j  a  va 2s.com
    return null;
}

From source file:org.olat.user.restapi.UserVOFactory.java

/**
 * Allow the value of gender to be in the raw form (male, female key word) or
 * to be translated//www.j  a  va  2  s  . c o  m
 * @param value
 * @param handler
 * @param locale
 * @return
 */
public static final String parseGender(String value, GenderPropertyHandler handler, Locale locale) {
    if (!StringHelper.containsNonWhitespace(value)) {
        value = "-";
    }

    int index = Arrays.binarySearch(UserVOFactory.keys, value);
    if (index < 0) {
        //try to translate them
        boolean found = false;
        Translator trans = Util.createPackageTranslator(GenderPropertyHandler.class, locale);
        for (String key : keys) {
            String translation = trans.translate(handler.i18nFormElementLabelKey() + "." + key);
            if (translation.equals(value)) {
                value = key;
                found = true;
                break;
            }
        }

        if (!found && !locale.equals(I18nModule.getDefaultLocale())) {
            //very last chance, try with the default locale
            trans = Util.createPackageTranslator(GenderPropertyHandler.class, I18nModule.getDefaultLocale());
            for (String key : keys) {
                String translation = trans.translate(handler.i18nFormElementLabelKey() + "." + key);
                if (translation.equals(value)) {
                    value = key;
                    found = true;
                    break;
                }
            }
        }
    }
    return value;
}

From source file:AntarcticaLocaleDemo.java

@Override
public DateFormat getDateInstance(int style, Locale locale) {
  if (locale.equals(antarctica)) {
    return new SimpleDateFormat("yyyy~MM~dd HH.mm.ss");
  }//from  www . j a v a2 s  .c om
  return null;
}

From source file:AntarcticaLocaleDemo.java

public DateFormat getTimeInstance(int style, Locale locale) {
    if (locale.equals(antarctica)) {
        return new SimpleDateFormat("HH.mm.ss");
    }/*from   ww w  .  java2s  . c  om*/
    return null;
}

From source file:AntarcticaLocaleDemo.java

public DateFormat getDateTimeInstance(int dateStyle, Locale locale) {
    if (locale.equals(antarctica)) {
        return new SimpleDateFormat("yyyy~MM~dd HH.mm.ss");
    }//from  ww  w . j  av a 2s.  com
    return null;
}

From source file:AntarcticaLocaleDemo.java

public DateFormat getDateTimeInstance(int dateStyle,
       int timeStyle, Locale locale) {
    if (locale.equals(antarctica)) {
        return new SimpleDateFormat("yyyy~MM~dd HH.mm.ss");
    }/*from w  w w  . j a v  a2 s  . c  o m*/
    return null;
}

From source file:rbcp.PropertiesResourceBundleControl.java

@Override
public List<Locale> getCandidateLocales(String baseName, Locale locale) {
    if (baseName == null)
        throw new NullPointerException();
    if (locale.equals(new Locale("zh", "HK"))) {
        return Arrays.asList(locale, Locale.TAIWAN,
                // no Locale.CHINESE here
                Locale.ROOT);//  w  w w.  j a  v  a 2  s  .c o  m
    } else if (locale.equals(Locale.TAIWAN)) {
        return Arrays.asList(locale,
                // no Locale.CHINESE here
                Locale.ROOT);
    }
    return super.getCandidateLocales(baseName, locale);
}

From source file:com.google.android.apps.mytracks.fragments.CheckUnitsDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Locale defaultLocale = Locale.getDefault();
    boolean defaultMetric = !defaultLocale.equals(Locale.US) && !defaultLocale.equals(Locale.UK);
    PreferencesUtils.setBoolean(getActivity(), R.string.metric_units_key, defaultMetric);
    final String metric = getString(R.string.settings_stats_units_metric);
    final String imperial = getString(R.string.settings_stats_units_imperial);
    final CharSequence[] items = defaultMetric ? new CharSequence[] { metric, imperial }
            : new CharSequence[] { imperial, metric };
    return new AlertDialog.Builder(getActivity())
            .setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
                @Override//from  w  ww  .  j ava 2 s.c o m
                public void onClick(DialogInterface dialog, int which) {
                    int position = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
                    PreferencesUtils.setBoolean(getActivity(), R.string.metric_units_key,
                            items[position].equals(metric));
                    onDone();
                }
            }).setSingleChoiceItems(items, 0, null).setTitle(R.string.settings_stats_units_title).create();
}

From source file:org.jasig.cas.web.view.CasReloadableMessageBundle.java

@Override
protected String getMessageInternal(final String code, final Object[] args, final Locale locale) {
    boolean foundCode = false;

    if (!locale.equals(Locale.ENGLISH)) {
        for (int i = 0; !foundCode && i < this.basenames.length; i++) {
            final String filename = this.basenames[i] + "_" + locale.getLanguage();

            logger.debug("Examining language bundle [{}] for the code [{}]", filename, code);
            final PropertiesHolder holder = this.getProperties(filename);
            foundCode = holder != null && holder.getProperties() != null && holder.getProperty(code) != null;
        }/*from w w w . ja va 2 s . com*/

        if (!foundCode) {
            logger.warn("The code [{}] cannot be found in the language bundle for the locale [{}]", code,
                    locale);
        }
    }
    return super.getMessageInternal(code, args, locale);
}