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-related String 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 or String representation. For the date sub-type, the time is guaranteed to be 00:00:00.000 and the semantic Calendar object to be in the UTC timezone. For the time sub-type, the date is guaranteed to be set to 1970-01-01 and the semantic Calendar object to be in the UTC timezone.
    • 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 specified Calendar value for the given semantic type.
      @NotNull java.lang.String map​(@NotNull java.lang.String value, @NotNull java.lang.String semanticType)
      Maps an original String representation to a suitable semantic String 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 a String value to a semantic Calendar 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 - The Calendar object to map
        semanticType - The semantic type to map value to; supported values are: SemanticDataType.DATE, SemanticDataType.TIME and SemanticDataType.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 a String value to a semantic Calendar 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 parse
        semanticType - The semantic type to map value to; supported values are: SemanticDataType.DATE, SemanticDataType.TIME and SemanticDataType.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 specified Calendar 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 for date. The string representation for the datetime semantic type will be formatted as an ISO-8601-compliant string.

        Parameters:
        value - The Calendar object to create a string representation for
        semanticType - 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 original String representation to a suitable semantic String 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 map
        semanticType - The semantic type
        Returns:
        The semantic string