T - the type of instances this Formatter can handle.public interface Formatter<T>
Strategy for parsing and formatting instances from and to their literal representation
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
format(T obj)
Formats an instance into its literal representation.
|
T |
parse(java.lang.String str)
Parses a literal representation into an instance of type
T. |
@Nullable
java.lang.String format(@Nullable
T obj)
Formats an instance into its literal representation.
The resulting String may be set as an argument to parse(java.lang.String)
resulting in a similar instance as the input.
obj - the instance to be formattedString representing the instance's state.@Nullable T parse(@Nullable java.lang.String str) throws ParseException
Parses a literal representation into an instance of type T.
The resulting instance T may be set as an argument to format(T)
resulting in an equal String as the input.
str - the String to be parsedT whose state is initialized given the
parameters of the input String.ParseException - if the String cannot be parsed.