Java Message Format formatString(String str, String pattern)

Here you can find the source of formatString(String str, String pattern)

Description

format String

License

Apache License

Declaration

public static String formatString(String str, String pattern) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.MessageFormat;

public class Main {
    public static String formatString(String str, String pattern) {
        if (str == null)
            return "";
        if (pattern == null || pattern.trim().equals("")) {
            return str;
        } else {/*from w  ww  .j  a v a 2s .  c o  m*/
            Object objs[] = new Object[1];
            objs[0] = str;
            return MessageFormat.format(pattern, objs);
        }
    }
}

Related

  1. formatResource(Object[] info, String require)
  2. formats(String pattern, Object... args)
  3. formatString(ResourceBundle resourceBundle, String key, Object data)
  4. formatString(String format, String arg1)
  5. formatString(String message, Object... args)