dynamically read/add value to the parameter of conf file with Properties

前端 未结 2 2074
栀梦
栀梦 2021-02-06 13:25

I have a message like below in my conf file.

text.message = Richard has to go to School in 01/06/2012 / 1days.

<
2条回答
  •  不思量自难忘°
    2021-02-06 13:41

    You can use the MessageFormat API for this.

    Kickoff example:

    text.message = {0} has to go to {1} in {2,date,dd/MM/yyyy} / {3}
    

    with

    String message = properties.getProperty("text.message");
    String formattedMessage = MessageFormat.format(message, "Richard", "School", new Date(), "1days");
    System.out.println(formattedMessage); // Richard has to go to School in 31/05/2012 / 1days
    

提交回复
热议问题