Class Strftime
strftime engine from glibc, writing straight into a
StringBuilder.
The structure follows
__strftime_internal
closely enough to be read side by side with it: one pass over the pattern, per-specifier state
for the flags, field width and E/O modifier, and two shared number emitters that
the numeric conversions jump to the way the C code jumps to do_number and
do_number_spacepad. Unknown conversions are echoed back literally, as glibc's
bad_format does, rather than reported as errors.
Besides the conversions POSIX requires, the GNU flags - _ 0 ^ #, the field width, and
the extensions %P %k %l %s are supported. The POSIX + flag is supported as well,
which glibc itself does not parse.
Three places adapt glibc's locale database to what the JDK exposes, and so are ports in spirit rather than in letter:
- glibc's
nl_get_alt_digitreturns a whole alternative numeral per value; the JDK only offers a zero digit throughDecimalStyle, soOshifts each rendered digit instead, and keeps the padding glibc's alternative path skips. - glibc's
era_formatis a locale-supplied sub-pattern; the JDK has no equivalent field, so%EYformats through a CLDR era-and-year pattern. %cuses glibc's C-locale fallback"%a %b %e %H:%M:%S %Y"rather than a localized date-time pattern, which is the layout this library has always produced, while%xand%Xare localized.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidformat(StringBuilder out, CharSequence pattern, Locale locale) time()
-
Constructor Details
-
Strftime
public Strftime()
-
-
Method Details
-
time
- Returns:
- the fields to format, to be filled by the caller before
format(java.lang.StringBuilder, java.lang.CharSequence, java.util.Locale)
-
format
-