Package org.apache.calcite.util.format
Interface FormatElement
- All Known Implementing Classes:
FormatElementEnum
public interface FormatElement
A format element in a format string. Knows how to parse and unparse itself.
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
flatten
(Consumer<FormatElement> consumer) Applies a consumer to a format element.void
format
(StringBuilder sb, Date date) Formats a date to its appropriate string representation for the element.Returns the description of an element.void
Adds the appropriateSimpleDateFormat
pattern for the element to provided StringBuilder.
-
Method Details
-
format
Formats a date to its appropriate string representation for the element. -
toPattern
Adds the appropriateSimpleDateFormat
pattern for the element to provided StringBuilder.Note that certain FormatElements may not have a Java equivalent. In such cases, calling this method will throw an
UnsupportedOperationException
. SeeFormatElementEnum.Q
as an example.- Throws:
UnsupportedOperationException
-
getDescription
String getDescription()Returns the description of an element.For example,
%H
in MySQL represents the hour in 24-hour format (e.g., 00..23). This method returns the string "The hour (24-hour clock) as a decimal number (00-23)", which is the description ofFormatElementEnum.HH24
. -
flatten
Applies a consumer to a format element.
-