Class ReformatDateService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.metadata.MetadataServiceImpl
-
- com.adaptris.core.services.metadata.ReformatMetadata
-
- com.adaptris.core.services.metadata.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 ReformatMetadataReformats 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 valuesSECONDS_SINCE_EPOCHandMILLISECONDS_SINCE_EPOCHwhich describe the number of seconds and milliseconds since midnight Jan 1, 1970 UTC respectively. If specified as the source format, then thelongvalue will be converted into aDatebefore formatting (scientific notation is supported as perBigDecimal(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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.adaptris.core.services.metadata.MetadataServiceImpl
MetadataServiceImpl.LogWrapper
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.services.metadata.MetadataServiceImpl
DEBUG, ERROR, INFO, TRACE, WARN
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description ReformatDateService()ReformatDateService(java.lang.String regexp)ReformatDateService(java.lang.String regexp, DateFormatBuilder srcFormat, DateFormatBuilder destFormat)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DateFormatBuildergetDestinationFormatBuilder()DateFormatBuildergetSourceFormatBuilder()java.lang.Stringreformat(java.lang.String s, AdaptrisMessage msg)Reformat a metadata valuevoidsetDestinationFormatBuilder(DateFormatBuilder destinationFormatBuilder)voidsetSourceFormatBuilder(DateFormatBuilder sourceFormatBuilder)-
Methods inherited from class com.adaptris.core.services.metadata.ReformatMetadata
doService, getMetadataKeyRegexp, setMetadataKeyRegexp
-
Methods inherited from class com.adaptris.core.services.metadata.MetadataServiceImpl
closeService, getMetadataLogger, initService, logMetadata, logMetadata, logMetadata, logMetadata, prepare, setMetadataLogger, withMetadataLogger
-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId, start, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.services.metadata.MetadataReformatter
reformat
-
-
-
-
Constructor Detail
-
ReformatDateService
public ReformatDateService()
-
ReformatDateService
public ReformatDateService(java.lang.String regexp)
-
ReformatDateService
public ReformatDateService(java.lang.String regexp, DateFormatBuilder srcFormat, DateFormatBuilder destFormat)
-
-
Method Detail
-
reformat
public java.lang.String reformat(java.lang.String s, AdaptrisMessage msg) throws java.lang.ExceptionDescription copied from interface:MetadataReformatterReformat a metadata value- Parameters:
s- the string to reformatmsg- the current Mesage.- Returns:
- the replacment string.
- Throws:
java.lang.Exception
-
getSourceFormatBuilder
public DateFormatBuilder getSourceFormatBuilder()
-
setSourceFormatBuilder
public void setSourceFormatBuilder(DateFormatBuilder sourceFormatBuilder)
-
getDestinationFormatBuilder
public DateFormatBuilder getDestinationFormatBuilder()
-
setDestinationFormatBuilder
public void setDestinationFormatBuilder(DateFormatBuilder destinationFormatBuilder)
-
-