Top Description Fields Constructors Methods
org.apache.xmpbox

public final Class DateConverter

extends Object
Class Inheritance
Imports
java.io.IOException, java.text.ParseException, .SimpleDateFormat, java.time.ZonedDateTime, java.time.format.DateTimeFormatter, java.util.Calendar, .Date, .GregorianCalendar, .Locale, .SimpleTimeZone, .TimeZone, java.util.regex.Matcher, .Pattern

This class is used to convert dates to strings and back using the PDF date standards. Date are described in PDFReference1.4 section 3.8.2

This is (and will not be) a Java date parsing library and will likely still have limited support for various strings as it’s main use case it to parse from PDF date strings.

Authors
Ben Litchfield, Christopher Oezbek

Field Summary

Modifier and TypeField and Description
private static final SimpleDateFormat[]

Constructor Summary

AccessConstructor and Description
private
DateConverter()

According to check-style, Utility classes should not have a public or default constructor.

Method Summary

Modifier and TypeMethod and Description
private static Calendar

Returns:

the Calendar instance.
fromISO8601
(String dateString)

Get a Calendar from an ISO8601 date string.

public static Calendar

Returns:

The calendar that this string represents.
toCalendar
(String
The string representation of the calendar.
date
)

This will convert a string to a calendar.

public static String

Returns:

The date represented as an ISO 8601 string.
toISO8601
(Calendar
The date to convert.
cal
)

Convert the date to iso 8601 string format.

public static String

Returns:

The date represented as an ISO 8601 string.
toISO8601
(Calendar
The date to convert.
cal
,
boolean
Print Milliseconds.
printMillis
)

Convert the date to iso 8601 string format.

private static void
updateZoneId(TimeZone
the time zone to update.
tz
)

Update the zone ID based on the raw offset.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

POTENTIAL_FORMATSback to summary
private static final SimpleDateFormat[] POTENTIAL_FORMATS

Constructor Detail

DateConverterback to summary
private DateConverter()

According to check-style, Utility classes should not have a public or default constructor.

Method Detail

fromISO8601back to summary
private static Calendar fromISO8601(String dateString)

Get a Calendar from an ISO8601 date string.

Returns:Calendar

the Calendar instance.

toCalendarback to summary
public static Calendar toCalendar(String date) throws IOException

This will convert a string to a calendar.

Parameters
date:String

The string representation of the calendar.

Returns:Calendar

The calendar that this string represents.

Exceptions
IOException:
If the date string is not in the correct format.
toISO8601back to summary
public static String toISO8601(Calendar cal)

Convert the date to iso 8601 string format.

Parameters
cal:Calendar

The date to convert.

Returns:String

The date represented as an ISO 8601 string.

toISO8601back to summary
public static String toISO8601(Calendar cal, boolean printMillis)

Convert the date to iso 8601 string format.

Parameters
cal:Calendar

The date to convert.

printMillis:boolean

Print Milliseconds.

Returns:String

The date represented as an ISO 8601 string.

updateZoneIdback to summary
private static void updateZoneId(TimeZone tz)

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:TimeZone

the time zone to update.