当前位置: 首页>>代码示例>>Java>>正文


Java Locale.ROOT属性代码示例

本文整理汇总了Java中java.util.Locale.ROOT属性的典型用法代码示例。如果您正苦于以下问题:Java Locale.ROOT属性的具体用法?Java Locale.ROOT怎么用?Java Locale.ROOT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.util.Locale的用法示例。


在下文中一共展示了Locale.ROOT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeLocalizedLevelName

private String computeLocalizedLevelName(Locale newLocale) {
    ResourceBundle rb = ResourceBundle.getBundle(resourceBundleName, newLocale);
    final String localizedName = rb.getString(name);

    final boolean isDefaultBundle = defaultBundle.equals(resourceBundleName);
    if (!isDefaultBundle) return localizedName;

    // This is a trick to determine whether the name has been translated
    // or not. If it has not been translated, we need to use Locale.ROOT
    // when calling toUpperCase().
    final Locale rbLocale = rb.getLocale();
    final Locale locale =
            Locale.ROOT.equals(rbLocale)
            || name.equals(localizedName.toUpperCase(Locale.ROOT))
            ? Locale.ROOT : rbLocale;

    // ALL CAPS in a resource bundle's message indicates no translation
    // needed per Oracle translation guideline.  To workaround this
    // in Oracle JDK implementation, convert the localized level name
    // to uppercase for compatibility reason.
    return Locale.ROOT.equals(locale) ? name : localizedName.toUpperCase(locale);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:Level.java

示例2: toLocaleArray

public static Locale[] toLocaleArray(Set<String> tags) {
    Locale[] locs = new Locale[tags.size() + 1];
    int index = 0;
    locs[index++] = Locale.ROOT;
    for (String tag : tags) {
        switch (tag) {
        case "ja-JP-JP":
            locs[index++] = JRELocaleConstants.JA_JP_JP;
            break;
        case "th-TH-TH":
            locs[index++] = JRELocaleConstants.TH_TH_TH;
            break;
        default:
            locs[index++] = Locale.forLanguageTag(tag);
            break;
        }
    }
    return locs;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:LocaleProviderAdapter.java

示例3: parse

/**
 * Parse the string describing a locale into a {@link Locale} object
 */
public static Locale parse(String localeStr) {
    final String[] parts = localeStr.split("_", -1);
    switch (parts.length) {
        case 3:
            // lang_country_variant
            return new Locale(parts[0], parts[1], parts[2]);
        case 2:
            // lang_country
            return new Locale(parts[0], parts[1]);
        case 1:
            if ("ROOT".equalsIgnoreCase(parts[0])) {
                return Locale.ROOT;
            }
            // lang
            return new Locale(parts[0]);
        default:
            throw new IllegalArgumentException("Can't parse locale: [" + localeStr + "]");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:LocaleUtils.java

示例4: toBundleName

@Override
public String toBundleName(String baseName, Locale locale) {
	if (locale == Locale.ROOT) return baseName;

	String language = locale.getLanguage();
	String script = locale.getScript();
	String country = locale.getCountry();
	String variant = locale.getVariant();

	if (Objects.equals(language, "") && Objects.equals(country, "") && Objects.equals(variant, "")) return baseName;

	StringBuilder sb = new StringBuilder(baseName);
	if (!baseName.endsWith("/"))
		sb.append('_');
	if (!Objects.equals(script, "")) if (!Objects.equals(variant, ""))
		sb.append(language).append('_').append(script).append('_').append(country).append('_').append(variant);
	else if (!Objects.equals(country, ""))
		sb.append(language).append('_').append(script).append('_').append(country);
	else sb.append(language).append('_').append(script);
	else if (!Objects.equals(variant, ""))
		sb.append(language).append('_').append(country).append('_').append(variant);
	else if (!Objects.equals(country, "")) sb.append(language).append('_').append(country);
	else sb.append(language);
	return sb.toString();

}
 
开发者ID:HuajiStudio,项目名称:ChessMaster,代码行数:26,代码来源:UTF8Control.java

示例5: getDays

private List<Day> getDays(Elements tableHeaderCells) throws ParseException {
    List<Day> days = new ArrayList<>();

    for (int i = 2; i < 7; i++) {
        String[] dayHeaderCell = tableHeaderCells.get(i).html().split("<br>");

        SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy", Locale.ROOT);
        Date d = sdf.parse(dayHeaderCell[1].trim());
        sdf.applyPattern("yyyy-MM-dd");

        Day day = new Day();
        day.setDayName(dayHeaderCell[0]);
        day.setDate(sdf.format(d));

        if (tableHeaderCells.get(i).hasClass("free-day")) {
            day.setFreeDay(true);
            day.setFreeDayName(dayHeaderCell[2]);
        }

        days.add(day);
    }

    return days;
}
 
开发者ID:wulkanowy,项目名称:wulkanowy,代码行数:24,代码来源:Timetable.java

示例6: getStrictStandardDateFormatter

public static FormatDateTimeFormatter getStrictStandardDateFormatter() {
    // 2014/10/10
    DateTimeFormatter shortFormatter = new DateTimeFormatterBuilder()
            .appendFixedDecimal(DateTimeFieldType.year(), 4)
            .appendLiteral('/')
            .appendFixedDecimal(DateTimeFieldType.monthOfYear(), 2)
            .appendLiteral('/')
            .appendFixedDecimal(DateTimeFieldType.dayOfMonth(), 2)
            .toFormatter()
            .withZoneUTC();

    // 2014/10/10 12:12:12
    DateTimeFormatter longFormatter = new DateTimeFormatterBuilder()
            .appendFixedDecimal(DateTimeFieldType.year(), 4)
            .appendLiteral('/')
            .appendFixedDecimal(DateTimeFieldType.monthOfYear(), 2)
            .appendLiteral('/')
            .appendFixedDecimal(DateTimeFieldType.dayOfMonth(), 2)
            .appendLiteral(' ')
            .appendFixedSignedDecimal(DateTimeFieldType.hourOfDay(), 2)
            .appendLiteral(':')
            .appendFixedSignedDecimal(DateTimeFieldType.minuteOfHour(), 2)
            .appendLiteral(':')
            .appendFixedSignedDecimal(DateTimeFieldType.secondOfMinute(), 2)
            .toFormatter()
            .withZoneUTC();

    DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder().append(longFormatter.withZone(DateTimeZone.UTC).getPrinter(), new DateTimeParser[]{longFormatter.getParser(), shortFormatter.getParser(), new EpochTimeParser(true)});

    return new FormatDateTimeFormatter("yyyy/MM/dd HH:mm:ss||yyyy/MM/dd||epoch_millis", builder.toFormatter().withZone(DateTimeZone.UTC), Locale.ROOT);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:31,代码来源:Joda.java

示例7: getDateTest

@Test
public void getDateTest() throws Exception {
    DateFormat format = new SimpleDateFormat("dd.MM.yyyy", Locale.ROOT);
    format.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date date = format.parse("31.07.2017");

    Assert.assertEquals(date, TimeUtils.getDate(636370560000000000L));
}
 
开发者ID:wulkanowy,项目名称:wulkanowy,代码行数:8,代码来源:TimeUtilsTest.java

示例8: readObject

/**
 * Reads the default serializable fields, provides default values for objects
 * in older serial versions, and initializes non-serializable fields.
 * If <code>serialVersionOnStream</code>
 * is less than 1, initializes <code>monetarySeparator</code> to be
 * the same as <code>decimalSeparator</code> and <code>exponential</code>
 * to be 'E'.
 * If <code>serialVersionOnStream</code> is less than 2,
 * initializes <code>locale</code>to the root locale, and initializes
 * If <code>serialVersionOnStream</code> is less than 3, it initializes
 * <code>exponentialSeparator</code> using <code>exponential</code>.
 * Sets <code>serialVersionOnStream</code> back to the maximum allowed value so that
 * default serialization will work properly if this object is streamed out again.
 * Initializes the currency from the intlCurrencySymbol field.
 *
 * @since JDK 1.1.6
 */
private void readObject(ObjectInputStream stream)
        throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    if (serialVersionOnStream < 1) {
        // Didn't have monetarySeparator or exponential field;
        // use defaults.
        monetarySeparator = decimalSeparator;
        exponential       = 'E';
    }
    if (serialVersionOnStream < 2) {
        // didn't have locale; use root locale
        locale = Locale.ROOT;
    }
    if (serialVersionOnStream < 3) {
        // didn't have exponentialSeparator. Create one using exponential
        exponentialSeparator = Character.toString(exponential);
    }
    serialVersionOnStream = currentSerialVersion;

    if (intlCurrencySymbol != null) {
        try {
             currency = Currency.getInstance(intlCurrencySymbol);
        } catch (IllegalArgumentException e) {
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:43,代码来源:DecimalFormatSymbols.java

示例9: doXContentBody

@Override
protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException {
    super.doXContentBody(builder, includeDefaults, params);

    if (includeDefaults || fieldType().numericPrecisionStep() != Defaults.PRECISION_STEP_64_BIT) {
        builder.field("precision_step", fieldType().numericPrecisionStep());
    }
    builder.field("format", fieldType().dateTimeFormatter().format());
    if (includeDefaults || fieldType().nullValueAsString() != null) {
        builder.field("null_value", fieldType().nullValueAsString());
    }
    if (includeInAll != null) {
        builder.field("include_in_all", includeInAll);
    } else if (includeDefaults) {
        builder.field("include_in_all", false);
    }

    if (includeDefaults || fieldType().timeUnit() != Defaults.TIME_UNIT) {
        builder.field("numeric_resolution", fieldType().timeUnit().name().toLowerCase(Locale.ROOT));
    }
    // only serialize locale if needed, ROOT is the default, so no need to serialize that case as well...
    if (fieldType().dateTimeFormatter().locale() != null && fieldType().dateTimeFormatter().locale() != Locale.ROOT) {
        builder.field("locale", fieldType().dateTimeFormatter().locale());
    } else if (includeDefaults) {
        if (fieldType().dateTimeFormatter().locale() == null) {
            builder.field("locale", Locale.ROOT);
        } else {
            builder.field("locale", fieldType().dateTimeFormatter().locale());
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:31,代码来源:DateFieldMapper.java

示例10: format

/**
 * Returns the formatted message for an exception with the specified messages.
 */
public static String format(String heading, Collection<Message> errorMessages) {
    try (Formatter fmt = new Formatter(Locale.ROOT)) {
        fmt.format(heading).format(":%n%n");
        int index = 1;
        boolean displayCauses = getOnlyCause(errorMessages) == null;

        for (Message errorMessage : errorMessages) {
            fmt.format("%s) %s%n", index++, errorMessage.getMessage());

            List<Object> dependencies = errorMessage.getSources();
            for (int i = dependencies.size() - 1; i >= 0; i--) {
                Object source = dependencies.get(i);
                formatSource(fmt, source);
            }

            Throwable cause = errorMessage.getCause();
            if (displayCauses && cause != null) {
                StringWriter writer = new StringWriter();
                cause.printStackTrace(new PrintWriter(writer));
                fmt.format("Caused by: %s", writer.getBuffer());
            }

            fmt.format("%n");
        }

        if (errorMessages.size() == 1) {
            fmt.format("1 error");
        } else {
            fmt.format("%s errors", errorMessages.size());
        }

        return fmt.toString();
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:37,代码来源:Errors.java

示例11: data_localeList

@DataProvider(name = "localeList")
Locale[] data_localeList() {
    return new Locale[] {
            Locale.US,
            Locale.GERMAN,
            Locale.JAPAN,
            Locale.ROOT,
    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:TestChronoField.java

示例12: format

/**
 * Formats a filter and handles encoding of special characters in the value arguments using the
 * &lt;valueencoding&gt; rule as described in <a href="http://www.ietf.org/rfc/rfc4515.txt">RFC 4515</a>.
 * <p>
 * Example of filter template format: <code>(&amp;(cn={0})(uid={1}))</code>
 * 
 * @param filterTemplate the filter with placeholders
 * @param values the values to encode and substitute
 * @return the formatted filter with escaped values
 * @throws IllegalArgumentException if the number of values does not match the number of placeholders in the template
 */
public static String format( String filterTemplate, String... values )
{
    if ( values == null )
    {
        values = EMPTY;
    }

    MessageFormat mf = new MessageFormat( filterTemplate, Locale.ROOT );

    // check element count and argument count
    Format[] formats = mf.getFormatsByArgumentIndex();
    if ( formats.length != values.length )
    {
        // TODO: I18n
        String msg = "Filter template {0} has {1} placeholders but {2} arguments provided.";
        throw new IllegalArgumentException( I18n.format( msg, filterTemplate, formats.length, values.length ) );
    }

    // encode arguments
    for ( int i = 0; i < values.length; i++ )
    {
        values[i] = encodeFilterValue( values[i] );
    }

    // format the filter
    return mf.format( values );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:38,代码来源:FilterEncoder.java

示例13: getDisplayLocaleOfSubtypeLocale

@Nonnull
public static Locale getDisplayLocaleOfSubtypeLocale(@Nonnull final String localeString) {
    if (NO_LANGUAGE.equals(localeString)) {
        return sResources.getConfiguration().locale;
    }
    if (sExceptionalLocaleDisplayedInRootLocale.containsKey(localeString)) {
        return Locale.ROOT;
    }
    return LocaleUtils.constructLocaleFromString(localeString);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:10,代码来源:SubtypeLocaleUtils.java

示例14: readObject

/**
 * Reads the default serializable fields, provides default values for objects
 * in older serial versions, and initializes non-serializable fields.
 * If <code>serialVersionOnStream</code>
 * is less than 1, initializes <code>monetarySeparator</code> to be
 * the same as <code>decimalSeparator</code> and <code>exponential</code>
 * to be 'E'.
 * If <code>serialVersionOnStream</code> is less than 2,
 * initializes <code>locale</code>to the root locale, and initializes
 * If <code>serialVersionOnStream</code> is less than 3, it initializes
 * <code>exponentialSeparator</code> using <code>exponential</code>.
 * Sets <code>serialVersionOnStream</code> back to the maximum allowed value so that
 * default serialization will work properly if this object is streamed out again.
 * Initializes the currency from the intlCurrencySymbol field.
 *
 * @since  1.1.6
 */
private void readObject(ObjectInputStream stream)
        throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    if (serialVersionOnStream < 1) {
        // Didn't have monetarySeparator or exponential field;
        // use defaults.
        monetarySeparator = decimalSeparator;
        exponential       = 'E';
    }
    if (serialVersionOnStream < 2) {
        // didn't have locale; use root locale
        locale = Locale.ROOT;
    }
    if (serialVersionOnStream < 3) {
        // didn't have exponentialSeparator. Create one using exponential
        exponentialSeparator = Character.toString(exponential);
    }
    serialVersionOnStream = currentSerialVersion;

    if (intlCurrencySymbol != null) {
        try {
             currency = Currency.getInstance(intlCurrencySymbol);
        } catch (IllegalArgumentException e) {
        }
        currencyInitialized = true;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:44,代码来源:DecimalFormatSymbols.java

示例15: generateDatedExportFileName

public static String generateDatedExportFileName() {
    Calendar now = Calendar.getInstance();
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ROOT);

    return String.format("%s_%s.%s", EXPORT_FILENAME_PREFIX, dateFormat.format(now.getTime()), EXPORT_FILENAME_SUFFIX);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:6,代码来源:SettingsExporter.java


注:本文中的java.util.Locale.ROOT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。