Class ReformatDateService

  • All Implemented Interfaces:
    AdaptrisComponent, ComponentLifecycle, ComponentLifecycleExtension, MessageEventGenerator, Service, MetadataReformatter, StateManagedComponent

    @ComponentProfile(summary="Reformat a data value stored in metadata",
                      tag="service,metadata,timestamp,datetime")
    public class ReformatDateService
    extends ReformatMetadata
    Reformats the date and time stored against a metadata key.

    Each matching metadata key from ReformatMetadata.getMetadataKeyRegexp() will be treated as a date to be reformatted.

    In addition to supporting all the patterns allowed by SimpleDateFormat, this service also supports the special values SECONDS_SINCE_EPOCH and MILLISECONDS_SINCE_EPOCH which describe the number of seconds and milliseconds since midnight Jan 1, 1970 UTC respectively. If specified as the source format, then the long value will be converted into a Date before formatting (scientific notation is supported as per BigDecimal(String)); if specified as the destination format, then the raw long value will be emitted.

    See Also:
    SimpleDateFormat, DateFormatUtil.CustomDateFormat

    In the adapter configuration file this class is aliased as reformat-date-service which is the preferred alternative to the fully qualified classname when building your configuration.

    • Constructor Detail

      • ReformatDateService

        public ReformatDateService()
      • ReformatDateService

        public ReformatDateService​(java.lang.String regexp)
    • Method Detail

      • reformat

        public java.lang.String reformat​(java.lang.String s,
                                         AdaptrisMessage msg)
                                  throws java.lang.Exception
        Description copied from interface: MetadataReformatter
        Reformat a metadata value
        Parameters:
        s - the string to reformat
        msg - the current Mesage.
        Returns:
        the replacment string.
        Throws:
        java.lang.Exception
      • setSourceFormatBuilder

        public void setSourceFormatBuilder​(DateFormatBuilder sourceFormatBuilder)
      • getDestinationFormatBuilder

        public DateFormatBuilder getDestinationFormatBuilder()
      • setDestinationFormatBuilder

        public void setDestinationFormatBuilder​(DateFormatBuilder destinationFormatBuilder)