Skip to content

autores-uk/format

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Document javadoc

AutoRes Format

A better java.text.MessageFormat.

// parse to immutable formatter
var expression = FormatExpression.parse("Hello, {0}!");
// format
String result = expression.format(Locale.getDefault(), "World");
// print "Hello, World!"
System.out.println(result);

Features

  • Immutable, thread-safe parsed expressions
  • Supports JDK23 expressions at lower JDK versions
  • Exposes more parsed expression metadata

Implementation Notes

  • FormatExpression uses the same format types for numbers, lists and date/times as MessageFormat for compatibility reasons
  • Parsing ListFormat expressions like {0,list} is supported in JDK8+ but formatting such expressions requires a JDK22+ runtime
  • Format types attempt to solve two problems - format and parse; this library only formats

Building

Source and target are JDK8. Requires JDK23 to execute unit tests.

Use Maven wrapper scripts to build:

code/format/mvnw -f code/format/pom.xml clean install

Published artifacts can be found in the Maven Central Repository.