@ComponentProfile(summary="Reformat a data value stored in metadata", tag="service,metadata,timestamp,datetime") public class ReformatDateService extends ReformatMetadata
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.
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.
MetadataServiceImpl.LogWrapper
DEBUG, ERROR, INFO, TRACE, WARN
log
Constructor and Description |
---|
ReformatDateService() |
ReformatDateService(java.lang.String regexp) |
ReformatDateService(java.lang.String regexp,
DateFormatBuilder srcFormat,
DateFormatBuilder destFormat) |
Modifier and Type | Method and Description |
---|---|
DateFormatBuilder |
getDestinationFormatBuilder() |
DateFormatBuilder |
getSourceFormatBuilder() |
java.lang.String |
reformat(java.lang.String s,
AdaptrisMessage msg)
Reformat a metadata value
|
void |
setDestinationFormatBuilder(DateFormatBuilder destinationFormatBuilder) |
void |
setSourceFormatBuilder(DateFormatBuilder sourceFormatBuilder) |
doService, getMetadataKeyRegexp, setMetadataKeyRegexp
closeService, getMetadataLogger, initService, logMetadata, logMetadata, logMetadata, logMetadata, prepare, setMetadataLogger, withMetadataLogger
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
reformat
public ReformatDateService()
public ReformatDateService(java.lang.String regexp)
public ReformatDateService(java.lang.String regexp, DateFormatBuilder srcFormat, DateFormatBuilder destFormat)
public java.lang.String reformat(java.lang.String s, AdaptrisMessage msg) throws java.lang.Exception
MetadataReformatter
s
- the string to reformatmsg
- the current Mesage.java.lang.Exception
public DateFormatBuilder getSourceFormatBuilder()
public void setSourceFormatBuilder(DateFormatBuilder sourceFormatBuilder)
public DateFormatBuilder getDestinationFormatBuilder()
public void setDestinationFormatBuilder(DateFormatBuilder destinationFormatBuilder)