How to have placeholder for variable value in Java Text Block?

You can use %s as a placeholder in text blocks: String str = “”” { “someKey”: “someValue”, “date”: %s, } “”” and replace it using format() method. String.format(str, LocalDate.now()); From JEP 378 docs: A cleaner alternative is to use String::replace or String::format, as follows: String code = “”” public void print($type o) { System.out.println(Objects.toString(o)); } … Read more

tech