字符串占位符替换
- Spring字符串占位符替换
import org.springframework.util.PropertyPlaceholderHelper; import java.util.Properties; public class PlaceholderUtil { private static PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper( "#{", "}", ":", false); public static String replacePlaceholders(String value, final Properties properties) { return helper.replacePlaceholders(value, properties); } }
- String字符串替换(日期/数字等)
String time = String.format("%tc", date);
- slfj MessageFormatter
Object[] valueArr= {"aaa", 123}; MessageFormatter.arrayFormat("str {} int {}", valueArr).getMessage(); // {} 定位变量位置 // \{} 表示 跳过该对括号 // 前面再加 \ 则取消跳过