I'm using Spring with Java 8.
I have a string with parameters and I am not sure how should I updates the parameters by list of params.
String message = "Today is {0} and {1} is happy";
List<String> params = Arrays.asList("Sunday", "Uri", "Dan");
I would like to know with which operator should I use in order to get :
String newMessage = "Today is Sunday and Uri is happy.";
Thanks you
You can use MessageFormat like this :
String result = MessageFormat.format(message, params.toArray());
Output
Today is Sunday and Uri is happy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With