public class DateFormatProcessor extends AbstractProcessor<DateFormatProcessor.Input,DateFormatProcessor.Output>
Example Configuration:
attributes:
...
timezone: !string
default: PST
processors:
...
- !dateFormat
pattern: "EEEEE dd MMMMM yyyy HH:mm"
Will take into account the "lang" field, if passed in the request:
{
"lang": "fr_CH",
"attributes": {
...
"timezone": "CET"
},
...
}
In your template, you can use it like that:
<jasperReport>
<parameter name="dateFormat" class="java.text.DateFormat"/>
...
<textField>
...
<textFieldExpression>$P{dateFormat}.format(TODAY())</textFieldExpression>
</textField>
</jasperReport>
| Modifier and Type | Class and Description |
|---|---|
static class |
DateFormatProcessor.Input
The Input of the processor.
|
static class |
DateFormatProcessor.Output
The output of the processor.
|
AbstractProcessor.ContextProcessor.ExecutionContextMDC_JOB_ID_KEY| Modifier | Constructor and Description |
|---|---|
protected |
DateFormatProcessor()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
DateFormatProcessor.Input |
createInputParameter()
Returns a new/clean instance of a parameter object.
|
DateFormatProcessor.Output |
execute(DateFormatProcessor.Input values,
Processor.ExecutionContext context)
Perform the process on the input attributes.
|
protected void |
extraValidation(java.util.List<java.lang.Throwable> validationErrors,
Configuration configuration)
Perform any extra validation a subclass may need to perform.
|
void |
setPattern(java.lang.String pattern)
The pattern to use to format dates.
|
getInputMapperBiMap, getInputPrefix, getOutputMapperBiMap, getOutputPrefix, getOutputType, setInputMapper, setInputPrefix, setOutputMapper, setOutputPrefix, setPrefix, toString, toString, validateprotected void extraValidation(java.util.List<java.lang.Throwable> validationErrors,
Configuration configuration)
AbstractProcessorextraValidation in class AbstractProcessor<DateFormatProcessor.Input,DateFormatProcessor.Output>validationErrors - a list to add errors to so that all validation errors are reported as
one.configuration - the containing configuration@Nullable public DateFormatProcessor.Input createInputParameter()
ProcessorValues object.
The way the properties will be looked up is to
Values object using the mapped
property name
HasDefaultValue annotation is on the field for
the property.
@Nullable public DateFormatProcessor.Output execute(DateFormatProcessor.Input values, Processor.ExecutionContext context) throws java.lang.Exception
Processorvalues - A Java object whose public fields are populated from the Values object (which is used for transferring properties between
processors).context - The execution context for a print task.Values object. The key in the
Values
object is the name of the field or if there is a mapping in the Processor.getOutputMapperBiMap()
map, the mapped name. The key is determined in a similar way as for the input object.java.lang.Exceptionpublic void setPattern(java.lang.String pattern)
See https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
pattern - The pattern