Package com.itextpdf.kernel.pdf
Class PdfDate
- java.lang.Object
-
- com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfString>
-
- com.itextpdf.kernel.pdf.PdfDate
-
public class PdfDate extends PdfObjectWrapper<PdfString>
PdfDate
is the PDF date object.PDF defines a standard date format. The PDF date format closely follows the format defined by the international standard ASN.1 (Abstract Syntax Notation One, defined in CCITT X.208 or ISO/IEC 8824). A date is a
PdfString
of the form:(D:YYYYMMDDHHmmSSOHH'mm')
See also ISO-320001 7.9.4, "Dates".
- See Also:
PdfString
,GregorianCalendar
-
-
Field Summary
Fields Modifier and Type Field Description private static int[]
DATE_SPACE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.Calendar
decode(java.lang.String s)
Converts a PDF string representing a date into aCalendar
.private static java.lang.String
generateStringByCalendar(java.util.Calendar d)
java.lang.String
getW3CDate()
Gives the W3C format of the PdfDate.static java.lang.String
getW3CDate(java.lang.String d)
Gives the W3C format of thePdfDate
.protected boolean
isWrappedObjectMustBeIndirect()
Defines if the object behind this wrapper must be an indirect object in the resultant document.private static java.lang.String
setLength(int i, int length)
Adds a number of leading zeros to a givenString
in order to get aString
of a certain length.-
Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, flush, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
-
-
-
-
Method Detail
-
getW3CDate
public java.lang.String getW3CDate()
Gives the W3C format of the PdfDate.- Returns:
- a formatted date
-
getW3CDate
public static java.lang.String getW3CDate(java.lang.String d)
Gives the W3C format of thePdfDate
.- Parameters:
d
- the date in the format D:YYYYMMDDHHmmSSOHH'mm'- Returns:
- a formatted date
-
decode
public static java.util.Calendar decode(java.lang.String s)
Converts a PDF string representing a date into aCalendar
.- Parameters:
s
- the PDF string representing a date- Returns:
- a
Calendar
representing the date ornull
if the string was not a date
-
isWrappedObjectMustBeIndirect
protected boolean isWrappedObjectMustBeIndirect()
Description copied from class:PdfObjectWrapper
Defines if the object behind this wrapper must be an indirect object in the resultant document.
If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.
Return value of this method shouldn't depend on any logic, it should return always true or false.- Specified by:
isWrappedObjectMustBeIndirect
in classPdfObjectWrapper<PdfString>
- Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-
generateStringByCalendar
private static java.lang.String generateStringByCalendar(java.util.Calendar d)
-
setLength
private static java.lang.String setLength(int i, int length)
Adds a number of leading zeros to a givenString
in order to get aString
of a certain length.- Parameters:
i
- a given numberlength
- the length of the resultingString
- Returns:
- the resulting
String
-
-