This commit is contained in:
Looly
2020-10-27 10:50:03 +08:00
parent 0c6bd4e7dc
commit c138eb5028
2 changed files with 6 additions and 1 deletions

View File

@@ -2709,7 +2709,6 @@ public class StrUtil {
/**
* 有序的格式化文本,使用{number}做为占位符<br>
* 例:<br>
* 通常使用format("this is {0} for {1}", "a", "b") =》 this is a for b<br>
*
* @param pattern 文本格式

View File

@@ -465,4 +465,10 @@ public class StrUtilTest {
Assert.assertTrue(StrUtil.startWith(a, b));
Assert.assertFalse(StrUtil.startWithIgnoreEquals(a, b));
}
@Test
public void indexedFormatTest() {
final String ret = StrUtil.indexedFormat("this is {0} for {1}", "a", 1000);
Assert.assertEquals("this is a for 1,000", ret);
}
}