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 java.lang.String
format(@NotNull java.util.Calendar value, @NotNull java.lang.String semanticType)
Gets a string representation of the specifiedCalendar
value for the given semantic type.@NotNull java.lang.String
map(@NotNull java.lang.String value, @NotNull java.lang.String semanticType)
Maps an originalString
representation to a suitable semanticString
representation.@Nullable java.util.Calendar
map(@NotNull java.util.Calendar value, @NotNull java.lang.String semanticType)
Maps an original Calendar object to a semantic Calendar object.@Nullable java.util.Calendar
parse(@NotNull java.lang.String value, @NotNull java.lang.String semanticType)
Parses aString
value to a semanticCalendar
object.
-
-
-
Method Detail
-
map
@Nullable @Nullable java.util.Calendar map(@NotNull @NotNull java.util.Calendar value, @NotNull @NotNull java.lang.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 java.util.Calendar parse(@NotNull @NotNull java.lang.String value, @NotNull @NotNull java.lang.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 java.lang.String format(@NotNull @NotNull java.util.Calendar value, @NotNull @NotNull java.lang.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 java.lang.String map(@NotNull @NotNull java.lang.String value, @NotNull @NotNull java.lang.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
-
-