com.itextpdf.xmp.impl
Class XMPDateTimeImpl

java.lang.Object
  extended by com.itextpdf.xmp.impl.XMPDateTimeImpl
All Implemented Interfaces:
XMPDateTime, Comparable

public class XMPDateTimeImpl
extends Object
implements XMPDateTime

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
XMPDateTimeImpl()
          Creates an XMPDateTime-instance with the current time in the default time zone.
XMPDateTimeImpl(Calendar calendar)
          Creates an XMPDateTime-instance from a calendar.
XMPDateTimeImpl(Date date, TimeZone timeZone)
          Creates an XMPDateTime-instance from a Date and a TimeZone.
XMPDateTimeImpl(String strValue)
          Creates an XMPDateTime-instance from an ISO 8601 string.
 
Method Summary
 int compareTo(Object dt)
           
 Calendar getCalendar()
           
 int getDay()
           
 int getHour()
           
 String getISO8601String()
           
 int getMinute()
           
 int getMonth()
           
 int getNanoSecond()
           
 int getSecond()
           
 TimeZone getTimeZone()
           
 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 hasTimeZone()
          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)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XMPDateTimeImpl

public XMPDateTimeImpl()
Creates an XMPDateTime-instance with the current time in the default time zone.


XMPDateTimeImpl

public XMPDateTimeImpl(Calendar calendar)
Creates an XMPDateTime-instance from a calendar.

Parameters:
calendar - a Calendar

XMPDateTimeImpl

public XMPDateTimeImpl(Date date,
                       TimeZone timeZone)
Creates an XMPDateTime-instance from a Date and a TimeZone.

Parameters:
date - a date describing an absolute point in time
timeZone - a TimeZone how to interpret the date

XMPDateTimeImpl

public XMPDateTimeImpl(String strValue)
                throws XMPException
Creates an XMPDateTime-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 Detail

getYear

public int getYear()
Specified by:
getYear in interface XMPDateTime
Returns:
Returns the year, can be negative.
See Also:
XMPDateTime.getYear()

setYear

public void setYear(int year)
Specified by:
setYear in interface XMPDateTime
Parameters:
year - Sets the year
See Also:
XMPDateTime.setYear(int)

getMonth

public int getMonth()
Specified by:
getMonth in interface XMPDateTime
Returns:
Returns The month in the range 1..12.
See Also:
XMPDateTime.getMonth()

setMonth

public void setMonth(int month)
Specified by:
setMonth in interface XMPDateTime
Parameters:
month - Sets the month 1..12
See Also:
XMPDateTime.setMonth(int)

getDay

public int getDay()
Specified by:
getDay in interface XMPDateTime
Returns:
Returns the day of the month in the range 1..31.
See Also:
XMPDateTime.getDay()

setDay

public void setDay(int day)
Specified by:
setDay in interface XMPDateTime
Parameters:
day - Sets the day 1..31
See Also:
XMPDateTime.setDay(int)

getHour

public int getHour()
Specified by:
getHour in interface XMPDateTime
Returns:
Returns hour - The hour in the range 0..23.
See Also:
XMPDateTime.getHour()

setHour

public void setHour(int hour)
Specified by:
setHour in interface XMPDateTime
Parameters:
hour - Sets the hour in the range 0..23.
See Also:
XMPDateTime.setHour(int)

getMinute

public int getMinute()
Specified by:
getMinute in interface XMPDateTime
Returns:
Returns the minute in the range 0..59.
See Also:
XMPDateTime.getMinute()

setMinute

public void setMinute(int minute)
Specified by:
setMinute in interface XMPDateTime
Parameters:
minute - Sets the minute in the range 0..59.
See Also:
XMPDateTime.setMinute(int)

getSecond

public int getSecond()
Specified by:
getSecond in interface XMPDateTime
Returns:
Returns the second in the range 0..59.
See Also:
XMPDateTime.getSecond()

setSecond

public void setSecond(int second)
Specified by:
setSecond in interface XMPDateTime
Parameters:
second - Sets the second in the range 0..59.
See Also:
XMPDateTime.setSecond(int)

getNanoSecond

public int getNanoSecond()
Specified by:
getNanoSecond in interface XMPDateTime
Returns:
Returns milli-, micro- and nano seconds. Nanoseconds within a second, often left as zero?
See Also:
XMPDateTime.getNanoSecond()

setNanoSecond

public void setNanoSecond(int nanoSecond)
Specified by:
setNanoSecond in interface XMPDateTime
Parameters:
nanoSecond - Sets the milli-, micro- and nano seconds. Granularity goes down to milli seconds.
See Also:
XMPDateTime.setNanoSecond(int)

compareTo

public int compareTo(Object dt)
Specified by:
compareTo in interface Comparable
See Also:
Comparable.compareTo(Object)

getTimeZone

public TimeZone getTimeZone()
Specified by:
getTimeZone in interface XMPDateTime
Returns:
Returns the time zone.
See Also:
XMPDateTime.getTimeZone()

setTimeZone

public void setTimeZone(TimeZone timeZone)
Specified by:
setTimeZone in interface XMPDateTime
Parameters:
timeZone - a time zone to set
See Also:
XMPDateTime.setTimeZone(TimeZone)

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 interface XMPDateTime
Returns:
Returns true if the XMPDateTime object has a date portion.
See Also:
XMPDateTime.hasDate()

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 interface XMPDateTime
Returns:
Returns true if the XMPDateTime object has a time portion.
See Also:
XMPDateTime.hasTime()

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 interface XMPDateTime
Returns:
Returns true if the XMPDateTime object has a defined timezone.
See Also:
XMPDateTime.hasTimeZone()

getCalendar

public Calendar getCalendar()
Specified by:
getCalendar in interface XMPDateTime
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:
XMPDateTime.getCalendar()

getISO8601String

public String getISO8601String()
Specified by:
getISO8601String in interface XMPDateTime
Returns:
Returns the ISO 8601 string representation of the date and time.
See Also:
XMPDateTime.getISO8601String()

toString

public String toString()
Overrides:
toString in class Object
Returns:
Returns the ISO string representation.


Copyright © 2013. All Rights Reserved.