Package org.apache.xmpbox
Class DateConverter
- java.lang.Object
-
- org.apache.xmpbox.DateConverter
-
public final class DateConverter extends java.lang.Object
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.2This 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.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.text.SimpleDateFormat[]
POTENTIAL_FORMATS
-
Constructor Summary
Constructors Modifier Constructor Description private
DateConverter()
According to check-style, Utility classes should not have a public or default constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.util.Calendar
fromISO8601(java.lang.String dateString)
Get a Calendar from an ISO8601 date string.static java.util.Calendar
toCalendar(java.lang.String date)
This will convert a string to a calendar.static java.lang.String
toISO8601(java.util.Calendar cal)
Convert the date to iso 8601 string format.static java.lang.String
toISO8601(java.util.Calendar cal, boolean printMillis)
Convert the date to iso 8601 string format.private static void
updateZoneId(java.util.TimeZone tz)
Update the zone ID based on the raw offset.
-
-
-
Method Detail
-
toCalendar
public static java.util.Calendar toCalendar(java.lang.String date) throws java.io.IOException
This will convert a string to a calendar.- Parameters:
date
- The string representation of the calendar.- Returns:
- The calendar that this string represents.
- Throws:
java.io.IOException
- If the date string is not in the correct format.
-
updateZoneId
private static void updateZoneId(java.util.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
- the time zone to update.
-
toISO8601
public static java.lang.String toISO8601(java.util.Calendar cal)
Convert the date to iso 8601 string format.- Parameters:
cal
- The date to convert.- Returns:
- The date represented as an ISO 8601 string.
-
toISO8601
public static java.lang.String toISO8601(java.util.Calendar cal, boolean printMillis)
Convert the date to iso 8601 string format.- Parameters:
cal
- The date to convert.printMillis
- Print Milliseconds.- Returns:
- The date represented as an ISO 8601 string.
-
fromISO8601
private static java.util.Calendar fromISO8601(java.lang.String dateString)
Get a Calendar from an ISO8601 date string.- Parameters:
dateString
-- Returns:
- the Calendar instance.
-
-