Java Message Format format(String message, Object argument)

Here you can find the source of format(String message, Object argument)

Description

Formats the given string with the given argument.

License

Open Source License

Parameter

Parameter Description
message the message to format, must not be <code>null</code>
argument the argument used to format the string

Return

the formatted string

Declaration

public static String format(String message, Object argument) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2005, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:// w  w  w  . ja  va2 s  . co m
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

import java.text.MessageFormat;

public class Main {
    /**
     * Formats the given string with the given argument.
     *
     * @param message the message to format, must not be <code>null</code>
     * @param argument the argument used to format the string
     * @return the formatted string
     */
    public static String format(String message, Object argument) {
        return MessageFormat.format(message, new Object[] { argument });
    }

    /**
     * Formats the given string with the given argument.
     *
     * @param message the message to format, must not be <code>null</code>
     * @param arguments the arguments used to format the string
     * @return the formatted string
     */
    public static String format(String message, Object[] arguments) {
        return MessageFormat.format(message, arguments);
    }
}

Related

  1. format(final String message, final Object... args)
  2. format(final String template, final Object... arguments)
  3. format(ResourceBundle bundle, String key, Object... args)
  4. format(String activity, Object item, Long count, Long total)
  5. format(String key, Object... values)
  6. format(String message, Object object)
  7. format(String message, Object parameter)
  8. format(String message, Object... params)
  9. format(String pattern, Map params)