Class CurrentDatePlaceholderPopulator
java.lang.Object
com.itextpdf.commons.actions.producer.AbstractFormattedPlaceholderPopulator
com.itextpdf.commons.actions.producer.CurrentDatePlaceholderPopulator
- All Implemented Interfaces:
IPlaceholderPopulator
Class is used to populate
currentDate
placeholder. Placeholder should be configured
with parameter defining the format of date output. Within format strings, unquoted letters from
A
to Z
and from a
to z
are process as pattern
letters. Chain of equal pattern letters forms an appropriate component of
currentDate
format. There following components are supported:
d
is for the day of the month, from 1 through 31dd
is for the day of the month, from 01 through 31M
defines the month from 1 to 12MM
defines the month from 01 to 12MMM
defines the abbreviated name of the monthMMMM
defines the full name of monthyy
means the year from 00 to 99yyyy
means the year in for digits formats
shows current second, from 0 through 59ss
shows current second, from 00 through 59m
is replaced with the current minute from 0 to 59mm
is replaced with the current minute from 00 to 59H
stands for the current hour, using a 24-hour clock from 0 to 23HH
stands for the current hour, using a 24-hour clock from 00 to 23
Text can be quoted using single quotes (') to avoid interpretation. All other characters are not
interpreted and just copied into the output string. String may contain escaped apostrophes
\'
which processed as characters. Backslash is used for escaping so you need double
backslash to print it \\
. All the rest backslashes (not followed by apostrophe or
one more backslash) are simply ignored.
The result of the processing is current date representing in accordance with the provided format.
-
Field Summary
FieldsFields inherited from class com.itextpdf.commons.actions.producer.AbstractFormattedPlaceholderPopulator
APOSTROPHE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate String
formatDate
(Date date, String format) populate
(List<ConfirmedEventWrapper> events, String parameter) Builds a replacement for a placeholdercurrentDate
in accordance with the provided format.private int
processDateComponent
(int index, Date date, StringBuilder builder, char[] formatArray) Methods inherited from class com.itextpdf.commons.actions.producer.AbstractFormattedPlaceholderPopulator
attachQuotedString, isLetter
-
Field Details
-
ALLOWED_PATTERNS
-
-
Constructor Details
-
CurrentDatePlaceholderPopulator
public CurrentDatePlaceholderPopulator()
-
-
Method Details
-
populate
Builds a replacement for a placeholdercurrentDate
in accordance with the provided format.- Parameters:
events
- is a list of event involved into document processing. It is not used during the placeholder replacementparameter
- defines output format in accordance with the description- Returns:
- date of producer line creation in accordance with defined format
- Throws:
IllegalArgumentException
- if format of the date pattern is invalid
-
formatDate
-
processDateComponent
-