MessageFormat nie formatuje tekstu.

0

Cześć,

mam takiego stringa String s = test's {0}" próbowałem też użyć takiego String s = test\u0027s {0}". Chcę go sformatować i wstawić jakiś text do niego.
Więc korzystam z MessageFormat.format(s, "one") w wyniku czego dostaję (w obu przypadkach) tests {0}. Po usunięciu apostrofu wszystko działa jak należy.
Nie bardzo rozumiem co ten apostrof zmienia? Jest mi ktoś wstanie wytłumaczyć co tu się dzieje? Próbowałem przeanalizować metodę formatującą, ale jest tak napisana, że jej nie rozumiem.

1

Z dokumentacji

Within a String, "''" represents a single quote. A QuotedString can contain arbitrary characters except single quotes; the surrounding single quotes are removed. An UnquotedString can contain arbitrary characters except single quotes and left curly brackets. Thus, a string that should result in the formatted message "'{0}'" can be written as "'''{'0}''" or "'''{0}'''".

Powinienes wiec uzyc

String s = "test''s {0}"

1 użytkowników online, w tym zalogowanych: 0, gości: 1