문서의 이전 판입니다!
{}
가 formatting anchor 이며, 이 부분이 파라미터 문자열로 대체된다.MessageFormat
보다 10배 정도 빠르다고 한다.MessageFormatter.format("Set {1,2,3} is not equal to {}.", "1,2"); -> "Set {1,2,3} is not equal to 1,2." // { 에대 한 escape 은 \\{ MessageFormatter.format("Set \\{} is not equal to {}.", "1,2"); -> "Set {} is not equal to 1,2." // \ 자체를 사용하려면 \\\\ MessageFormatter.format("File name is C:\\\\{}.", "file.zip"); -> "File name is C:\file.zip"
int planet = 7; String event = "a disturbance in the Force"; String result = MessageFormat.format( "At {1,time} on {1,date}, there was {2} on planet {0,number,integer}.", planet, new Date(), event); // 결과 At 12:30 PM on Jul 3, 2053, there was a disturbance in the Force on planet 7.