Example usage for java.util Locale toString

List of usage examples for java.util Locale toString

Introduction

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

Prototype

@Override
public final String toString() 

Source Link

Document

Returns a string representation of this Locale object, consisting of language, country, variant, script, and extensions as below:
language + "_" + country + "_" + (variant + "_#" | "#") + script + "_" + extensions
Language is always lower case, country is always upper case, script is always title case, and extensions are always lower case.

Usage

From source file:DateFormatDemo.java

static public void displayDate(Locale currentLocale) {

    Date today;/*w  w w  .j  a  v  a2s.com*/
    String dateOut;
    DateFormat dateFormatter;

    dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, currentLocale);
    today = new Date();
    dateOut = dateFormatter.format(today);

    System.out.println(dateOut + "   " + currentLocale.toString());
}

From source file:DateFormatDemo.java

static public void showBothStyles(Locale currentLocale) {

    Date today;//from   w  w w .  j a v a 2  s .c o  m
    String result;
    DateFormat formatter;

    int[] styles = { DateFormat.DEFAULT, DateFormat.SHORT, DateFormat.MEDIUM, DateFormat.LONG,
            DateFormat.FULL };

    System.out.println();
    System.out.println("Locale: " + currentLocale.toString());
    System.out.println();

    today = new Date();

    for (int k = 0; k < styles.length; k++) {
        formatter = DateFormat.getDateTimeInstance(styles[k], styles[k], currentLocale);
        result = formatter.format(today);
        System.out.println(result);
    }
}

From source file:org.apache.manifoldcf.core.i18n.Messages.java

protected static void complainMissingBundle(String errorMessage, Throwable exception, String bundleName,
        Locale locale) {
    String localeName = locale.toString();
    BundleKey bk = new BundleKey(bundleName, localeName);
    synchronized (bundleSet) {
        if (bundleSet.contains(bk))
            return;
        bundleSet.add(bk);// w  ww  .j  a  v  a 2 s. c o m
    }
    logError(errorMessage, exception);
}

From source file:DateFormatDemo.java

static public void showDateStyles(Locale currentLocale) {

    Date today = new Date();
    String result;//from   w w w  .j a  va2  s. co m
    DateFormat formatter;

    int[] styles = { DateFormat.DEFAULT, DateFormat.SHORT, DateFormat.MEDIUM, DateFormat.LONG,
            DateFormat.FULL };

    System.out.println();
    System.out.println("Locale: " + currentLocale.toString());
    System.out.println();

    for (int k = 0; k < styles.length; k++) {
        formatter = DateFormat.getDateInstance(styles[k], currentLocale);
        result = formatter.format(today);
        System.out.println(result);
    }
}

From source file:DateFormatDemo.java

static public void showTimeStyles(Locale currentLocale) {

    Date today = new Date();
    String result;//from w  w w.j av a2  s  .  c o  m
    DateFormat formatter;

    int[] styles = { DateFormat.DEFAULT, DateFormat.SHORT, DateFormat.MEDIUM, DateFormat.LONG,
            DateFormat.FULL };

    System.out.println();
    System.out.println("Locale: " + currentLocale.toString());
    System.out.println();

    for (int k = 0; k < styles.length; k++) {
        formatter = DateFormat.getTimeInstance(styles[k], currentLocale);
        result = formatter.format(today);
        System.out.println(result);
    }
}

From source file:net.ymate.platform.core.i18n.I18N.java

/**
 * @param locale       //from  ww w . j  a  v  a2 s.co m
 * @param resourceName ???
 * @return ????
 */
protected static List<String> __doGetResourceNames(Locale locale, String resourceName) {
    List<String> _names = new ArrayList<String>();
    _names.add(resourceName + ".properties");
    String _localeKey = (locale == null) ? "" : locale.toString();
    if (_localeKey.length() > 0) {
        resourceName += ("_" + _localeKey) + ".properties";
        _names.add(0, resourceName);
    }
    return _names;
}

From source file:org.apache.manifoldcf.core.i18n.Messages.java

protected static void complainMissingMessage(String errorMessage, Throwable exception, String bundleName,
        Locale locale, String messageKey) {
    String localeName = locale.toString();
    MessageKey bk = new MessageKey(bundleName, localeName, messageKey);
    synchronized (messageSet) {
        if (messageSet.contains(bk))
            return;
        messageSet.add(bk);/*  w  ww  .  j  av  a  2  s.c o  m*/
    }
    logError(errorMessage, exception);
}

From source file:org.apache.manifoldcf.core.i18n.Messages.java

protected static void complainMissingResource(String errorMessage, Throwable exception, String pathName,
        Locale locale, String resourceKey) {
    String localeName = locale.toString();
    ResourceKey bk = new ResourceKey(pathName, localeName, resourceKey);
    synchronized (resourceSet) {
        if (resourceSet.contains(bk))
            return;
        resourceSet.add(bk);/*from  ww w  . ja  va  2s  . c  o m*/
    }
    logError(errorMessage, exception);
}

From source file:com.yqboots.dict.core.DataDictManagerImpl.java

/**
 * Gets the cached key./*  ww w  . j av a  2  s  . c  o  m*/
 * @param name name
 * @param locale locale
 * @return the caching key
 */
private static String getCachedKey(final String name, final Locale locale) {
    return name + "_" + locale.toString();
}

From source file:org.encuestame.core.security.util.WidgetUtil.java

/**
 *
 * @param language//from w ww  .  j  a v a 2  s.com
 * @return
 */
public static String validateLocale(final String language) {
    try {
        final Locale locale = parseLocale(language);
        return locale.toString();
    } catch (Exception e) {
        return new Locale("en", "US").toString();
    }
}