Java Examples for java.util.Locale.Category

The following java examples will help you to understand the usage of java.util.Locale.Category. These source code samples are taken from different open source projects.

Example 1
Project: openjdk-master  File: PrintStream.java View source code
/**
     * Writes a formatted string to this output stream using the specified
     * format string and arguments.
     *
     * <p> The locale always used is the one returned by {@link
     * java.util.Locale#getDefault(Locale.Category)} with
     * {@link java.util.Locale.Category#FORMAT FORMAT} category specified,
     * regardless of any previous invocations of other formatting methods on
     * this object.
     *
     * @param  format
     *         A format string as described in <a
     *         href="../util/Formatter.html#syntax">Format string syntax</a>
     *
     * @param  args
     *         Arguments referenced by the format specifiers in the format
     *         string.  If there are more arguments than format specifiers, the
     *         extra arguments are ignored.  The number of arguments is
     *         variable and may be zero.  The maximum number of arguments is
     *         limited by the maximum dimension of a Java array as defined by
     *         <cite>The Java™ Virtual Machine Specification</cite>.
     *         The behaviour on a
     *         {@code null} argument depends on the <a
     *         href="../util/Formatter.html#syntax">conversion</a>.
     *
     * @throws  java.util.IllegalFormatException
     *          If a format string contains an illegal syntax, a format
     *          specifier that is incompatible with the given arguments,
     *          insufficient arguments given the format string, or other
     *          illegal conditions.  For specification of all possible
     *          formatting errors, see the <a
     *          href="../util/Formatter.html#detail">Details</a> section of the
     *          formatter class specification.
     *
     * @throws  NullPointerException
     *          If the {@code format} is {@code null}
     *
     * @return  This output stream
     *
     * @since  1.5
     */
public PrintStream format(String format, Object... args) {
    try {
        synchronized (this) {
            ensureOpen();
            if ((formatter == null) || (formatter.locale() != Locale.getDefault(Locale.Category.FORMAT)))
                formatter = new Formatter((Appendable) this);
            formatter.format(Locale.getDefault(Locale.Category.FORMAT), format, args);
        }
    } catch (InterruptedIOException x) {
        Thread.currentThread().interrupt();
    } catch (IOException x) {
        trouble = true;
    }
    return this;
}
Example 2
Project: wicket-master  File: DurationTest.java View source code
@Test
public void formatLocale() throws Exception {
    final Locale oldFormatLocale = Locale.getDefault(Category.FORMAT);
    final Locale oldDefaultLocale = Locale.getDefault();
    try {
        Locale.setDefault(Locale.US);
        Locale.setDefault(Category.FORMAT, Locale.GERMANY);
        assertEquals("should take formatting locale into account", "1,5 minutes", Duration.seconds(90).toString());
    } finally {
        Locale.setDefault(oldDefaultLocale);
        Locale.setDefault(Category.FORMAT, oldFormatLocale);
    }
}
Example 3
Project: Illarion-Java-master  File: IllaClient.java View source code
/**
     * Prepare the configuration system and the decryption system.
     */
private void prepareConfig() {
    cfg = new ConfigSystem(getFile("Illarion.xcfgz"));
    cfg.setDefault("debugLevel", 1);
    cfg.setDefault("showIDs", false);
    cfg.setDefault(Player.CFG_SOUND_ON, true);
    cfg.setDefault(Player.CFG_SOUND_VOL, Player.MAX_CLIENT_VOL);
    cfg.setDefault("musicOn", true);
    cfg.setDefault("musicVolume", Player.MAX_CLIENT_VOL * 0.25f);
    cfg.setDefault(ChatLog.CFG_TEXTLOG, true);
    cfg.setDefault(CFG_FULLSCREEN, false);
    GraphicResolution defaultResolution = new GraphicResolution();
    cfg.setDefault(CFG_RESOLUTION, defaultResolution.toString());
    cfg.setDefault("windowWidth", defaultResolution.getWidth());
    cfg.setDefault("windowHeight", defaultResolution.getHeight());
    cfg.setDefault("savePassword", false);
    cfg.setDefault("showFps", false);
    cfg.setDefault("showPing", false);
    cfg.setDefault(CrashReporter.CFG_KEY, CrashReporter.MODE_ASK);
    Locale locale = Locale.getDefault(Category.DISPLAY);
    // If the system locale is german, set to german. Otherwise, default to English
    if ("de".equals(locale.getLanguage())) {
        cfg.setDefault(Lang.LOCALE_CFG, Lang.LOCALE_CFG_GERMAN);
    } else {
        cfg.setDefault(Lang.LOCALE_CFG, Lang.LOCALE_CFG_ENGLISH);
    }
    cfg.setDefault("inventoryPosX", "100px");
    cfg.setDefault("inventoryPosY", "10px");
    cfg.setDefault("bookDisplayPosX", "150px");
    cfg.setDefault("bookDisplayPosY", "15px");
    cfg.setDefault("skillWindowPosX", "200px");
    cfg.setDefault("skillWindowPosY", "20px");
    cfg.setDefault("backpackDisplayPosX", "100px");
    cfg.setDefault("backpackDisplayPosY", "10px");
    cfg.setDefault("depotDisplayPosX", "150px");
    cfg.setDefault("depotDisplayPosY", "15px");
    cfg.setDefault("bagDisplayPosX", "200px");
    cfg.setDefault("bagDisplayPosY", "20px");
    cfg.setDefault("questWindowPosX", "100px");
    cfg.setDefault("questWindowPosY", "100px");
    cfg.setDefault("questShowFinished", false);
    cfg.setDefault("server", Servers.Devserver.getServerKey());
    cfg.setDefault("serverAddress", Servers.Customserver.getServerHost());
    cfg.setDefault("serverPort", Servers.Customserver.getServerPort());
    cfg.setDefault("clientVersion", Servers.Customserver.getClientVersion());
    cfg.setDefault("clientVersionOverwrite", false);
    cfg.setDefault("serverAccountLogin", true);
    cfg.setDefault("wasdWalk", true);
    cfg.setDefault("disableChatAfterSending", true);
    cfg.setDefault("showQuestsOnGameMap", true);
    cfg.setDefault("showQuestsOnMiniMap", true);
    /* Showing the avatar tag on a permanent base.
         * 0 -> none are shown
         * 1 -> other players only
         * 2 -> other players and monsters
         */
    cfg.setDefault("showAvatarTagPermanently", 0);
    cfg.set("limitPathFindingToMouseDirection", true);
    cfg.set("followMousePathFinding", true);
    cfg.setDefault("preLoadBagCount", 2);
    cfg.setDefault(Translator.CFG_KEY_PROVIDER, Translator.CFG_VALUE_PROVIDER_NONE);
    cfg.setDefault(Translator.CFG_KEY_DIRECTION, Translator.CFG_VALUE_DIRECTION_DEFAULT);
    @Nonnull Toolkit awtDefaultToolkit = Toolkit.getDefaultToolkit();
    @Nullable Object doubleClick = awtDefaultToolkit.getDesktopProperty("awt.multiClickInterval");
    if (doubleClick instanceof Number) {
        cfg.set("doubleClickInterval", ((Number) doubleClick).intValue());
    } else {
        cfg.set("doubleClickInterval", 500);
    }
    Crypto crypt = new Crypto();
    crypt.loadPublicKey();
    TableLoader.setCrypto(crypt);
}
Example 4
Project: jdk7u-jdk-master  File: LauncherHelper.java View source code
/*
     * prints the locale subopt/section
     */
private static void printLocale(PrintStream ostream) {
    Locale locale = Locale.getDefault();
    ostream.println(LOCALE_SETTINGS);
    ostream.println(INDENT + "default locale = " + locale.getDisplayLanguage());
    ostream.println(INDENT + "default display locale = " + Locale.getDefault(Category.DISPLAY).getDisplayName());
    ostream.println(INDENT + "default format locale = " + Locale.getDefault(Category.FORMAT).getDisplayName());
    printLocales(ostream);
    ostream.println();
}
Example 5
Project: openjdk8-jdk-master  File: LauncherHelper.java View source code
/*
     * prints the locale subopt/section
     */
private static void printLocale() {
    Locale locale = Locale.getDefault();
    ostream.println(LOCALE_SETTINGS);
    ostream.println(INDENT + "default locale = " + locale.getDisplayLanguage());
    ostream.println(INDENT + "default display locale = " + Locale.getDefault(Category.DISPLAY).getDisplayName());
    ostream.println(INDENT + "default format locale = " + Locale.getDefault(Category.FORMAT).getDisplayName());
    printLocales();
    ostream.println();
}
Example 6
Project: Terasology-master  File: SystemConfig.java View source code
public Locale getLocale() {
    if (locale == null) {
        setLocale(Locale.getDefault(Category.DISPLAY));
    }
    return Locale.forLanguageTag(locale);
}
Example 7
Project: package-drone-master  File: OsgiMessageInterpolator.java View source code
@Override
public String interpolate(final String message, final Context context) {
    return interpolate(message, context, Locale.getDefault(Category.DISPLAY));
}
Example 8
Project: j2objc-master  File: DecimalFormatSymbols.java View source code
// Android-changed: Removed reference to DecimalFormatSymbolsProvider.
/**
     * Gets the <code>DecimalFormatSymbols</code> instance for the default
     * locale.
     * <p>This is equivalent to calling
     * {@link #getInstance(Locale)
     *     getInstance(Locale.getDefault(Locale.Category.FORMAT))}.
     * @see java.util.Locale#getDefault(java.util.Locale.Category)
     * @see java.util.Locale.Category#FORMAT
     * @return a <code>DecimalFormatSymbols</code> instance.
     * @since 1.6
     */
public static final DecimalFormatSymbols getInstance() {
    return getInstance(Locale.getDefault(Locale.Category.FORMAT));
}
Example 9
Project: sandbox-master  File: SystemConfig.java View source code
public Locale getLocale() {
    if (locale == null) {
        setLocale(Locale.getDefault(Category.DISPLAY));
    }
    return Locale.forLanguageTag(locale);
}