Java Message Format format(String str, int replacement)

Here you can find the source of format(String str, int replacement)

Description

Formats the string with replacement values

License

Open Source License

Parameter

Parameter Description
str a parameter
replacement a parameter

Return

String

Declaration

public static String format(String str, int replacement) 

Method Source Code

//package com.java2s;
/**//from   w w w.  ja  v a 2s.  com
 * Aptana Studio
 * Copyright (c) 2005-2012 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions).
 * Please see the license.html included with this distribution for details.
 * Any modifications to this file must keep this entire header intact.
 */

import java.text.MessageFormat;

public class Main {
    /**
     * Formats the string with replacement values
     * 
     * @param str
     * @param replacement
     * @return String
     */
    public static String format(String str, int replacement) {
        return MessageFormat.format(str, new Object[] { Integer.toString(replacement) });
    }

    /**
     * Formats the string with replacement values
     * 
     * @param str
     * @param replacement
     * @return String
     */
    public static String format(String str, long replacement) {
        return MessageFormat.format(str, new Object[] { Long.toString(replacement) });
    }

    /**
     * Formats the string with replacement values
     * 
     * @param str
     * @param replacement
     * @return String
     */
    public static String format(String str, Object replacement) {
        return MessageFormat.format(str, new Object[] { replacement.toString() });
    }

    /**
     * Formats the string with replacement values
     * 
     * @param str
     * @param replacements
     * @return String
     */
    public static String format(String str, Object[] replacements) {
        return MessageFormat.format(str, replacements);
    }

    /**
     * Formats the string with replacement values
     * 
     * @param str
     * @param replacement
     * @return String
     */
    public static String format(String str, String replacement) {
        return MessageFormat.format(str, new Object[] { replacement });
    }
}

Related

  1. format(String message, Object parameter)
  2. format(String message, Object... params)
  3. format(String pattern, Map params)
  4. format(String pattern, Object... args)
  5. format(String pattern, String[] replacements)
  6. format(String str, Object... arguments)
  7. format(String textPattern, Object... args)
  8. formatAsNumber(double value)
  9. formatCause(final String message, final Throwable cause, final Object... args)