Java Locale Format formatMessage(@Nonnull ResourceBundle bundle, @Nonnull String messageKey, @Nullable Object... args)

Here you can find the source of formatMessage(@Nonnull ResourceBundle bundle, @Nonnull String messageKey, @Nullable Object... args)

Description

format Message

License

Mozilla Public License

Declaration

@Nonnull
    public static String formatMessage(@Nonnull ResourceBundle bundle, @Nonnull String messageKey,
            @Nullable Object... args) 

Method Source Code

//package com.java2s;
/*****************************************************************************************
 * *** BEGIN LICENSE BLOCK *****/*w w w  .  j a va  2s .c  o m*/
 *
 * Version: MPL 2.0
 *
 * echocat Jomon, Copyright (c) 2012-2013 echocat
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * *** END LICENSE BLOCK *****
 ****************************************************************************************/

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.text.MessageFormat;
import java.util.ResourceBundle;

public class Main {
    @Nonnull
    public static String formatMessage(@Nonnull ResourceBundle bundle, @Nonnull String messageKey,
            @Nullable Object... args) {
        final String plainMessage = bundle.getString(messageKey);
        final String message = new MessageFormat(plainMessage, bundle.getLocale()).format(args);
        return message;
    }
}

Related

  1. formatIntWithCommas(int num)
  2. formatLines(String target, int maxLength, Locale currentLocale)
  3. formatLocaleDate(final java.util.Date date)
  4. formatLocaleTime(long time, Locale locale)
  5. formatMailDate(Date date)
  6. formatMessage(String messageKey, Locale locale)
  7. formatMysqlDate(final Date date)
  8. formatNumber(double d, String pattern)
  9. formatNumber(long number)