A better java.text.MessageFormat.
// parse to immutable, thread-safe formatter
var expression = FormatExpression.parse("Hello, {0}!");
// format
String result = expression.format(Locale.getDefault(), "World");
// print "Hello, World!"
System.out.println(result);- Immutable, thread-safe parsed expressions
- Supports JDK23 expressions at lower JDK versions
- Exposes more parsed expression metadata
FormatExpressionuses the same Format types under the covers for numbers, lists and date/times asMessageFormatto ensure maximum compatibility with the runtime JDK- Format types attempt to solve two problems - format and parse; this library only formats
- Parsing
ListFormat
expressions like
{0,list}is supported in JDK17+ but formatting such expressions requires a JDK22+ runtime
Published artifacts can be found in the Maven Central Repository.
Version numbers follow a JDK.Major.Minor scheme.
Source and target are JDK17. Requires JDK23 to execute unit tests.
Use Maven wrapper scripts to build:
code/format/mvnw -f code/format/pom.xml clean installDevelopment is done on the main branch.
Releases are tagged as release/$version.