Module dev.metaschema.core
Class DateTimeFormatUtil
java.lang.Object
dev.metaschema.core.metapath.function.library.DateTimeFormatUtil
Utility class for parsing and formatting date/time picture strings as defined
in XPath
Functions 3.1 Section 9.8.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBase class for components of a parsed picture string.static classA literal text component in a picture string.static classA variable marker component in a picture string, representing a date/time component to be formatted. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatDateTime(ITemporalItem value, String picture, String language, String calendar, String place, Set<Character> allowedMarkers) Format a temporal value according to a picture string.parsePictureString(String picture) Parse a picture string into a list of format components.
-
Method Details
-
parsePictureString
@NonNull public static List<DateTimeFormatUtil.FormatComponent> parsePictureString(@NonNull String picture) Parse a picture string into a list of format components.The picture string consists of literal substrings and variable markers enclosed in square brackets. Doubled brackets
[[and]]are treated as escaped literal brackets.- Parameters:
picture- the picture string to parse- Returns:
- an unmodifiable list of format components
- Throws:
FormatDateTimeFunctionException- withFormatDateTimeFunctionException.INVALID_PICTURE_STRINGif the picture string syntax is invalid- See Also:
-
formatDateTime
@NonNull public static String formatDateTime(@NonNull ITemporalItem value, @NonNull String picture, @Nullable String language, @Nullable String calendar, @Nullable String place, @NonNull Set<Character> allowedMarkers) Format a temporal value according to a picture string.This method implements the formatting algorithm defined in XPath Functions 3.1 Section 9.8. The picture string is parsed into literal and variable marker components, and each variable marker is formatted according to its component specifier, presentation modifier, and width modifier.
- Parameters:
value- the temporal value to formatpicture- the picture stringlanguage- the language for names, ornullfor Englishcalendar- the calendar system, ornullfor Gregorianplace- the place for timezone, ornullallowedMarkers- the set of allowed component specifiers- Returns:
- the formatted string
- Throws:
FormatDateTimeFunctionException- if formatting fails
-