Package com.adobe.cq.dam.cfm.extensions
Interface SemanticDateTimeFormatter
-
@ProviderType public interface SemanticDateTimeFormatter
Provides services that allow to convert different date and time representations.Following representations are supported:
- Original - any
Calendar
object or date/time-relatedString
representation; may have any timezone setting and also unnormalized fields (see description of the semantic representation below for more information about normalization). - Semantic - normalized representations of an original
Calendar
object or date/time-related orString
representation. For thedate
sub-type, the time is guaranteed to be 00:00:00.000 and the semanticCalendar
object to be in the UTC timezone. For thetime
sub-type, the date is guaranteed to be set to 1970-01-01 and the semanticCalendar
object to be in the UTC timezone.
- Original - any
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @Nullable String
format(@NotNull Calendar value, @NotNull String semanticType)
Gets a string representation of the specifiedCalendar
value for the given semantic type.@NotNull String
map(@NotNull String value, @NotNull String semanticType)
Maps an originalString
representation to a suitable semanticString
representation.@Nullable Calendar
map(@NotNull Calendar value, @NotNull String semanticType)
Maps an original Calendar object to a semantic Calendar object.@Nullable Calendar
parse(@NotNull String value, @NotNull String semanticType)
Parses aString
value to a semanticCalendar
object.
-
-
-
Method Detail
-
map
@Nullable @Nullable Calendar map(@NotNull @NotNull Calendar value, @NotNull @NotNull String semanticType)
Maps an original Calendar object to a semantic Calendar object.- Parameters:
value
- TheCalendar
object to mapsemanticType
- The semantic type to mapvalue
to; supported values are:SemanticDataType.DATE
,SemanticDataType.TIME
andSemanticDataType.DATETIME
- Returns:
- The mapped semantic
Calendar
-
parse
@Nullable @Nullable Calendar parse(@NotNull @NotNull String value, @NotNull @NotNull String semanticType)
Parses aString
value to a semanticCalendar
object.The format supported for strings is
[HH:mm[:ss]][yyyy-MM-dd['T'HH:mm:ss[.SSS][XXX]]
, which basically resembles ISO-8601.- Parameters:
value
- The string to parsesemanticType
- The semantic type to mapvalue
to; supported values are:SemanticDataType.DATE
,SemanticDataType.TIME
andSemanticDataType.DATETIME
- Returns:
- The semantic
Calendar
object that matches the parsed string;null
if the string doesn't contain a valid date
-
format
@Nullable @Nullable String format(@NotNull @NotNull Calendar value, @NotNull @NotNull String semanticType)
Gets a string representation of the specifiedCalendar
value for the given semantic type.The string representation will be hh:mm:ss[.n...] (nanosecond portion is optional) for the
time
semantic type and yyyy-mm-dd fordate
. The string representation for thedatetime
semantic type will be formatted as an ISO-8601-compliant string.- Parameters:
value
- TheCalendar
object to create a string representation forsemanticType
- the semantic type for the string representation- Returns:
- The string representation
-
map
@NotNull @NotNull String map(@NotNull @NotNull String value, @NotNull @NotNull String semanticType)
Maps an originalString
representation to a suitable semanticString
representation.The format supported for the returned value is
[HH:mm[:ss]][yyyy-MM-dd['T'HH:mm:ss[.SSS][XXX]]
, which basically resembles ISO-8601.- Parameters:
value
- The string to mapsemanticType
- The semantic type- Returns:
- The semantic string
-
-