Package org.apache.xmlgraphics.util
Class DateFormatUtil
- java.lang.Object
-
- org.apache.xmlgraphics.util.DateFormatUtil
-
public final class DateFormatUtil extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
ISO_8601_DATE_PATTERN
-
Constructor Summary
Constructors Modifier Constructor Description private
DateFormatUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
appendOffset(java.lang.StringBuilder sb, char delimiter, int offset, boolean endWithDelimiter)
private static void
appendOffsetNoUTC(java.lang.StringBuilder sb, char delimiter, int offset, boolean endWithDelimiter)
private static void
appendOffsetSign(java.lang.StringBuilder sb, int zoneOffsetHours)
private static void
appendOffsetUTC(java.lang.StringBuilder sb)
private static void
appendPaddedNumber(java.lang.StringBuilder sb, int number)
private static java.text.DateFormat
createDateFormat(java.lang.String format, java.util.TimeZone timeZone)
private static java.lang.String
formatDate(java.util.Date date, java.text.DateFormat dateFormat, char delimiter, boolean endWithDelimiter)
Formats the date according to the specified format and returns as a string.private static java.lang.String
formatDateToParse(java.lang.String date, java.lang.String errorMessage)
static java.lang.String
formatISO8601(java.util.Date date, java.util.TimeZone timeZone)
Formats the date according to ISO 8601 standard.static java.lang.String
formatPDFDate(java.util.Date date, java.util.TimeZone timeZone)
Formats the date according to PDF format.private static int
getOffsetInMinutes(java.util.Calendar cal)
static java.util.Date
parseISO8601Date(java.lang.String date)
Parses an ISO 8601 date and time value.
-
-
-
Field Detail
-
ISO_8601_DATE_PATTERN
private static final java.lang.String ISO_8601_DATE_PATTERN
- See Also:
- Constant Field Values
-
-
Method Detail
-
formatPDFDate
public static java.lang.String formatPDFDate(java.util.Date date, java.util.TimeZone timeZone)
Formats the date according to PDF format. See section 3.8.2 of the PDF 1.4 specification.- Parameters:
date
- The date time to formattimeZone
- The time zone used to format the date- Returns:
- a formatted date according to PDF format (based on ISO 8824)
-
formatISO8601
public static java.lang.String formatISO8601(java.util.Date date, java.util.TimeZone timeZone)
Formats the date according to ISO 8601 standard.- Parameters:
date
- The date time to formattimeZone
- The time zone used to format the date- Returns:
- a formatted date according to ISO 8601
-
createDateFormat
private static java.text.DateFormat createDateFormat(java.lang.String format, java.util.TimeZone timeZone)
-
formatDate
private static java.lang.String formatDate(java.util.Date date, java.text.DateFormat dateFormat, char delimiter, boolean endWithDelimiter)
Formats the date according to the specified format and returns as a string.- Parameters:
date
- The date / time object to formatdateFormat
- The date format to use when outputting the datedelimiter
- The character used to separate the time zone difference hours and minutesendWithDelimiter
- Determines whether the date string will end with the delimiter character- Returns:
- the formatted date string
-
getOffsetInMinutes
private static int getOffsetInMinutes(java.util.Calendar cal)
-
appendOffset
private static void appendOffset(java.lang.StringBuilder sb, char delimiter, int offset, boolean endWithDelimiter)
-
appendOffsetUTC
private static void appendOffsetUTC(java.lang.StringBuilder sb)
-
appendOffsetNoUTC
private static void appendOffsetNoUTC(java.lang.StringBuilder sb, char delimiter, int offset, boolean endWithDelimiter)
-
appendOffsetSign
private static void appendOffsetSign(java.lang.StringBuilder sb, int zoneOffsetHours)
-
appendPaddedNumber
private static void appendPaddedNumber(java.lang.StringBuilder sb, int number)
-
parseISO8601Date
public static java.util.Date parseISO8601Date(java.lang.String date)
Parses an ISO 8601 date and time value.- Parameters:
date
- the date and time value as an ISO 8601 string- Returns:
- the parsed date/time
-
formatDateToParse
private static java.lang.String formatDateToParse(java.lang.String date, java.lang.String errorMessage)
-
-