In this question, it points out, It's possible to have something like:
message.myMessage = This message is for {0} in {1}
But I don't know how to pass parameter to it
MESSAGES.getString("message.myMessage", "foor", "bar")
but unfortunately getString can't know take other parameters Any idea?
The System class in Java provides a method named System. getenv() which can be used to get the value of an environment variable set in the current system.
I'm guessing you're thinking of MessageFormat? If so, it's just this:
String s = MessageFormat.format("This message is for {0} in {1}", "foo", "bar");
Or from properties:
Properties p = new Properties(); p.setProperty("messages.myMessage", "This message is for {0} in {1}"); String s = MessageFormat.format( p.getProperty("messages.myMessage"), "foo", "bar");
Try out this one:
String message = "This message is for {0} in {1}."; String result = MessageFormat.format(message, "me", "the next morning"); System.out.println(result);
(java.text.MessageFormat;
)
Or in JSF:
<h:outputFormat value="This message is for {0} in {1}."> <f:param value="me"> <f:param value="the next morning"> </h:outputFormat>
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