@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.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
CONFIRMATION_ID_KEY
Constructor and Description |
---|
ReformatDateService() |
ReformatDateService(java.lang.String regexp) |
ReformatDateService(java.lang.String regexp,
DateFormatBuilder srcFormat,
DateFormatBuilder destFormat) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getDestinationDateFormat()
Deprecated.
|
DateFormatBuilder |
getDestinationFormatBuilder() |
java.lang.String |
getSourceDateFormat()
Deprecated.
|
DateFormatBuilder |
getSourceFormatBuilder() |
protected void |
initService() |
java.lang.String |
reformat(java.lang.String s,
AdaptrisMessage msg)
Reformat a metadata value
|
void |
setDestinationDateFormat(java.lang.String s)
Deprecated.
since 3.6.6 use
setDestinationFormatBuilder(DateFormatBuilder) instead. |
void |
setDestinationFormatBuilder(DateFormatBuilder destinationFormatBuilder) |
void |
setSourceDateFormat(java.lang.String s)
Deprecated.
since 3.6.6 use
setSourceFormatBuilder(DateFormatBuilder) instead. |
void |
setSourceFormatBuilder(DateFormatBuilder sourceFormatBuilder) |
doService, getMetadataKeyRegexp, setMetadataKeyRegexp
closeService, getMetadataLogger, logMetadata, logMetadata, logMetadata, logMetadata, prepare, setMetadataLogger, withMetadataLogger
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsConfirmation, getIsTrackingEndpoint, getLookupName, getUniqueId, init, isBranching, isConfirmation, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, rethrowServiceException, retrieveComponentState, setContinueOnFail, setIsConfirmation, setIsTrackingEndpoint, setLookupName, 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
protected void initService() throws CoreException
initService
in class MetadataServiceImpl
CoreException
@Deprecated @Removal(version="3.9.0", message="Use sourceFormatBuilder") public java.lang.String getSourceDateFormat()
@Deprecated @Removal(version="3.9.0", message="Use sourceFormatBuilder") public void setSourceDateFormat(java.lang.String s)
setSourceFormatBuilder(DateFormatBuilder)
instead.s
- the sourceDateFormat to setSimpleDateFormat
@Deprecated @Removal(version="3.9.0", message="Use destinationFormatBuilder") public java.lang.String getDestinationDateFormat()
@Deprecated @Removal(version="3.9.0", message="Use destinationFormatBuilder") public void setDestinationDateFormat(java.lang.String s)
setDestinationFormatBuilder(DateFormatBuilder)
instead.s
- the destinationDateFormat to setSimpleDateFormat
public DateFormatBuilder getSourceFormatBuilder()
public void setSourceFormatBuilder(DateFormatBuilder sourceFormatBuilder)
public DateFormatBuilder getDestinationFormatBuilder()
public void setDestinationFormatBuilder(DateFormatBuilder destinationFormatBuilder)