Package com.itextpdf.kernel.xmp.impl
Class XMPDateTimeImpl
java.lang.Object
com.itextpdf.kernel.xmp.impl.XMPDateTimeImpl
- All Implemented Interfaces:
-
XMPDateTime
,Comparable
The implementation of
XMPDateTime
. Internally a calendar
is used plus an additional nano seconds field, because Calendar
supports only milli seconds. The nanoSeconds
convers only the resolution beyond a milli second.
- Since:
- 16.02.2006
-
Constructor Summary
ConstructorDescriptionCreates anXMPDateTime
-instance with the current time in the default time zone.XMPDateTimeImpl
(String strValue) Creates anXMPDateTime
-instance from an ISO 8601 string.XMPDateTimeImpl
(Calendar calendar) Creates anXMPDateTime
-instance from a calendar.XMPDateTimeImpl
(Date date, TimeZone timeZone) Creates anXMPDateTime
-instance from aDate
and aTimeZone
. -
Method Summary
Modifier and TypeMethodDescriptionint
int
getDay()
int
getHour()
int
int
getMonth()
int
int
int
getYear()
boolean
hasDate()
This flag is set either by parsing or by setting year, month or day.boolean
hasTime()
This flag is set either by parsing or by setting hours, minutes, seconds or milliseconds.boolean
This flag is set either by parsing or by setting hours, minutes, seconds or milliseconds.void
setDay
(int day) void
setHour
(int hour) void
setMinute
(int minute) void
setMonth
(int month) void
setNanoSecond
(int nanoSecond) void
setSecond
(int second) void
setTimeZone
(TimeZone timeZone) void
setYear
(int year) toString()
-
Constructor Details
-
XMPDateTimeImpl
public XMPDateTimeImpl()Creates anXMPDateTime
-instance with the current time in the default time zone. -
XMPDateTimeImpl
Creates anXMPDateTime
-instance from a calendar.- Parameters:
-
calendar
- aCalendar
-
XMPDateTimeImpl
Creates anXMPDateTime
-instance from aDate
and aTimeZone
.- Parameters:
-
date
- a date describing an absolute point in time -
timeZone
- a TimeZone how to interpret the date
-
XMPDateTimeImpl
Creates anXMPDateTime
-instance from an ISO 8601 string.- Parameters:
-
strValue
- an ISO 8601 string - Throws:
-
XMPException
- If the string is a non-conform ISO 8601 string, an exception is thrown
-
-
Method Details
-
getYear
public int getYear()- Specified by:
-
getYear
in interfaceXMPDateTime
- Returns:
- Returns the year, can be negative.
- See Also:
-
setYear
public void setYear(int year) - Specified by:
-
setYear
in interfaceXMPDateTime
- Parameters:
-
year
- Sets the year - See Also:
-
getMonth
public int getMonth()- Specified by:
-
getMonth
in interfaceXMPDateTime
- Returns:
- Returns The month in the range 1..12.
- See Also:
-
setMonth
public void setMonth(int month) - Specified by:
-
setMonth
in interfaceXMPDateTime
- Parameters:
-
month
- Sets the month 1..12 - See Also:
-
getDay
public int getDay()- Specified by:
-
getDay
in interfaceXMPDateTime
- Returns:
- Returns the day of the month in the range 1..31.
- See Also:
-
setDay
public void setDay(int day) - Specified by:
-
setDay
in interfaceXMPDateTime
- Parameters:
-
day
- Sets the day 1..31 - See Also:
-
getHour
public int getHour()- Specified by:
-
getHour
in interfaceXMPDateTime
- Returns:
- Returns hour - The hour in the range 0..23.
- See Also:
-
setHour
public void setHour(int hour) - Specified by:
-
setHour
in interfaceXMPDateTime
- Parameters:
-
hour
- Sets the hour in the range 0..23. - See Also:
-
getMinute
public int getMinute()- Specified by:
-
getMinute
in interfaceXMPDateTime
- Returns:
- Returns the minute in the range 0..59.
- See Also:
-
setMinute
public void setMinute(int minute) - Specified by:
-
setMinute
in interfaceXMPDateTime
- Parameters:
-
minute
- Sets the minute in the range 0..59. - See Also:
-
getSecond
public int getSecond()- Specified by:
-
getSecond
in interfaceXMPDateTime
- Returns:
- Returns the second in the range 0..59.
- See Also:
-
setSecond
public void setSecond(int second) - Specified by:
-
setSecond
in interfaceXMPDateTime
- Parameters:
-
second
- Sets the second in the range 0..59. - See Also:
-
getNanoSecond
public int getNanoSecond()- Specified by:
-
getNanoSecond
in interfaceXMPDateTime
- Returns:
- Returns milli-, micro- and nano seconds. Nanoseconds within a second, often left as zero?
- See Also:
-
setNanoSecond
public void setNanoSecond(int nanoSecond) - Specified by:
-
setNanoSecond
in interfaceXMPDateTime
- Parameters:
-
nanoSecond
- Sets the milli-, micro- and nano seconds. Granularity goes down to milli seconds. - See Also:
-
compareTo
- Specified by:
-
compareTo
in interfaceComparable
- See Also:
-
getTimeZone
- Specified by:
-
getTimeZone
in interfaceXMPDateTime
- Returns:
- Returns the time zone.
- See Also:
-
setTimeZone
- Specified by:
-
setTimeZone
in interfaceXMPDateTime
- Parameters:
-
timeZone
- a time zone to set - See Also:
-
hasDate
public boolean hasDate()Description copied from interface:XMPDateTime
This flag is set either by parsing or by setting year, month or day.- Specified by:
-
hasDate
in interfaceXMPDateTime
- Returns:
- Returns true if the XMPDateTime object has a date portion.
- See Also:
-
hasTime
public boolean hasTime()Description copied from interface:XMPDateTime
This flag is set either by parsing or by setting hours, minutes, seconds or milliseconds.- Specified by:
-
hasTime
in interfaceXMPDateTime
- Returns:
- Returns true if the XMPDateTime object has a time portion.
- See Also:
-
hasTimeZone
public boolean hasTimeZone()Description copied from interface:XMPDateTime
This flag is set either by parsing or by setting hours, minutes, seconds or milliseconds.- Specified by:
-
hasTimeZone
in interfaceXMPDateTime
- Returns:
- Returns true if the XMPDateTime object has a defined timezone.
- See Also:
-
getCalendar
- Specified by:
-
getCalendar
in interfaceXMPDateTime
- Returns:
-
Returns a
Calendar
(only with milli second precision).
Note: the dates before Oct 15th 1585 (which normally fall into validity of the Julian calendar) are also rendered internally as Gregorian dates. - See Also:
-
getISO8601String
- Specified by:
-
getISO8601String
in interfaceXMPDateTime
- Returns:
- Returns the ISO 8601 string representation of the date and time.
- See Also:
-
toString
-