Package org.apache.pdfbox.util
Class DateConverter
java.lang.Object
org.apache.pdfbox.util.DateConverter
Converts dates to strings and back using the PDF date standard
in section 3.8.2 of PDF Reference 1.7.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
(package private) static String
formatTZoffset
(long millis, String sep) (package private) static GregorianCalendar
newGreg()
private static GregorianCalendar
parseBigEndianDate
(String text, ParsePosition initialWhere) private static Calendar
parseDate
(String text, ParsePosition initialWhere) private static GregorianCalendar
parseSimpleDate
(String text, String[] fmts, ParsePosition initialWhere) private static int
parseTimeField
(String text, ParsePosition where, int maxlen, int remedy) (package private) static boolean
parseTZoffset
(String text, GregorianCalendar cal, ParsePosition initialWhere) private static int
restrainTZoffset
(long proposedOffset) private static char
skipOptionals
(String text, ParsePosition where, String optionals) private static boolean
skipString
(String text, String victim, ParsePosition where) static Calendar
toCalendar
(String text) Returns the Calendar for a given string containing a date, ornull
if it cannot be parsed.static Calendar
toCalendar
(COSString text) Returns the Calendar for a given COS string containing a date, ornull
if it cannot be parsed.static String
Converts the date to ISO 8601 string format: yyyy-mm-ddThh:MM:ss#hh:mm (where '#" is '+' or '-').static String
Converts a Calendar to a string formatted as: D:yyyyMMddHHmmss#hh'mm' where # is Z, +, or -.private static void
updateZoneId
(TimeZone tz) Update the zone ID based on the raw offset.
-
Field Details
-
MINUTES_PER_HOUR
private static final int MINUTES_PER_HOUR- See Also:
-
SECONDS_PER_MINUTE
private static final int SECONDS_PER_MINUTE- See Also:
-
MILLIS_PER_MINUTE
private static final int MILLIS_PER_MINUTE- See Also:
-
MILLIS_PER_HOUR
private static final int MILLIS_PER_HOUR- See Also:
-
HALF_DAY
private static final int HALF_DAY- See Also:
-
DAY
private static final int DAY- See Also:
-
ALPHA_START_FORMATS
-
DIGIT_START_FORMATS
-
-
Constructor Details
-
DateConverter
private DateConverter()
-
-
Method Details
-
toString
Converts a Calendar to a string formatted as: D:yyyyMMddHHmmss#hh'mm' where # is Z, +, or -.- Parameters:
cal
- The date to convert to a string. May be null. The DST_OFFSET is included when computing the output time zone.- Returns:
- The date as a String to be used in a PDF document, or null if the cal value is null
-
toISO8601
Converts the date to ISO 8601 string format: yyyy-mm-ddThh:MM:ss#hh:mm (where '#" is '+' or '-').- Parameters:
cal
- The date to convert. Must not be null. The DST_OFFSET is included in the output value.- Returns:
- The date represented as an ISO 8601 string.
-
restrainTZoffset
private static int restrainTZoffset(long proposedOffset) -
formatTZoffset
-
parseTimeField
-
skipOptionals
-
skipString
-
newGreg
-
adjustTimeZoneNicely
-
parseTZoffset
-
updateZoneId
Update the zone ID based on the raw offset. This is either GMT, GMT+hh:mm or GMT-hh:mm, where n is between 1 and 14. The highest negative hour is -14, the highest positive hour is 12. Zones that don't fit in this schema are set to zone ID "unknown".- Parameters:
tz
- the time zone to update.
-
parseBigEndianDate
-
parseSimpleDate
private static GregorianCalendar parseSimpleDate(String text, String[] fmts, ParsePosition initialWhere) -
parseDate
-
toCalendar
Returns the Calendar for a given COS string containing a date, ornull
if it cannot be parsed. The returned value will have 0 for DST_OFFSET.- Parameters:
text
- A COS string containing a date.- Returns:
- The Calendar that the text string represents, or
null
if it cannot be parsed.
-
toCalendar
Returns the Calendar for a given string containing a date, ornull
if it cannot be parsed. The returned value will have 0 for DST_OFFSET.- Parameters:
text
- A COS string containing a date.- Returns:
- The Calendar that the text string represents, or
null
if it cannot be parsed.
-