Package org.verapdf.xmp.impl
Class XMPDateTimeImpl
- java.lang.Object
-
- org.verapdf.xmp.impl.XMPDateTimeImpl
-
- All Implemented Interfaces:
Comparable,XMPDateTime
public class XMPDateTimeImpl extends Object implements XMPDateTime
The implementation ofXMPDateTime. Internally acalendaris used plus an additional nano seconds field, becauseCalendarsupports only milli seconds. ThenanoSecondsconvers only the resolution beyond a milli second.- Since:
- 16.02.2006
-
-
Constructor Summary
Constructors Constructor Description XMPDateTimeImpl()Creates 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 aDateand aTimeZone.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Object dt)CalendargetCalendar()intgetDay()intgetHour()StringgetISO8601String()intgetMinute()intgetMonth()intgetNanoSecond()intgetSecond()TimeZonegetTimeZone()intgetYear()booleanhasDate()This flag is set either by parsing or by setting year, month or day.booleanhasTime()This flag is set either by parsing or by setting hours, minutes, seconds or milliseconds.booleanhasTimeZone()This flag is set either by parsing or by setting hours, minutes, seconds or milliseconds.voidsetDay(int day)voidsetHour(int hour)voidsetMinute(int minute)voidsetMonth(int month)voidsetNanoSecond(int nanoSecond)voidsetSecond(int second)voidsetTimeZone(TimeZone timeZone)voidsetYear(int year)StringtoString()
-
-
-
Constructor Detail
-
XMPDateTimeImpl
public XMPDateTimeImpl()
Creates anXMPDateTime-instance with the current time in the default time zone.
-
XMPDateTimeImpl
public XMPDateTimeImpl(Calendar calendar)
Creates anXMPDateTime-instance from a calendar.- Parameters:
calendar- aCalendar
-
XMPDateTimeImpl
public XMPDateTimeImpl(Date date, TimeZone timeZone)
Creates anXMPDateTime-instance from aDateand aTimeZone.- Parameters:
date- a date describing an absolute point in timetimeZone- a TimeZone how to interpret the date
-
XMPDateTimeImpl
public XMPDateTimeImpl(String strValue) throws XMPException
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 Detail
-
getYear
public int getYear()
- Specified by:
getYearin interfaceXMPDateTime- Returns:
- Returns the year, can be negative.
- See Also:
XMPDateTime.getYear()
-
setYear
public void setYear(int year)
- Specified by:
setYearin interfaceXMPDateTime- Parameters:
year- Sets the year- See Also:
XMPDateTime.setYear(int)
-
getMonth
public int getMonth()
- Specified by:
getMonthin interfaceXMPDateTime- Returns:
- Returns The month in the range 1..12.
- See Also:
XMPDateTime.getMonth()
-
setMonth
public void setMonth(int month)
- Specified by:
setMonthin interfaceXMPDateTime- Parameters:
month- Sets the month 1..12- See Also:
XMPDateTime.setMonth(int)
-
getDay
public int getDay()
- Specified by:
getDayin interfaceXMPDateTime- Returns:
- Returns the day of the month in the range 1..31.
- See Also:
XMPDateTime.getDay()
-
setDay
public void setDay(int day)
- Specified by:
setDayin interfaceXMPDateTime- Parameters:
day- Sets the day 1..31- See Also:
XMPDateTime.setDay(int)
-
getHour
public int getHour()
- Specified by:
getHourin interfaceXMPDateTime- Returns:
- Returns hour - The hour in the range 0..23.
- See Also:
XMPDateTime.getHour()
-
setHour
public void setHour(int hour)
- Specified by:
setHourin interfaceXMPDateTime- Parameters:
hour- Sets the hour in the range 0..23.- See Also:
XMPDateTime.setHour(int)
-
getMinute
public int getMinute()
- Specified by:
getMinutein interfaceXMPDateTime- Returns:
- Returns the minute in the range 0..59.
- See Also:
XMPDateTime.getMinute()
-
setMinute
public void setMinute(int minute)
- Specified by:
setMinutein interfaceXMPDateTime- Parameters:
minute- Sets the minute in the range 0..59.- See Also:
XMPDateTime.setMinute(int)
-
getSecond
public int getSecond()
- Specified by:
getSecondin interfaceXMPDateTime- Returns:
- Returns the second in the range 0..59.
- See Also:
XMPDateTime.getSecond()
-
setSecond
public void setSecond(int second)
- Specified by:
setSecondin interfaceXMPDateTime- Parameters:
second- Sets the second in the range 0..59.- See Also:
XMPDateTime.setSecond(int)
-
getNanoSecond
public int getNanoSecond()
- Specified by:
getNanoSecondin interfaceXMPDateTime- 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:
setNanoSecondin interfaceXMPDateTime- 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:
compareToin interfaceComparable- See Also:
Comparable.compareTo(Object)
-
getTimeZone
public TimeZone getTimeZone()
- Specified by:
getTimeZonein interfaceXMPDateTime- Returns:
- Returns the time zone.
- See Also:
XMPDateTime.getTimeZone()
-
setTimeZone
public void setTimeZone(TimeZone timeZone)
- Specified by:
setTimeZonein interfaceXMPDateTime- Parameters:
timeZone- a time zone to set- See Also:
XMPDateTime.setTimeZone(TimeZone)
-
hasDate
public boolean hasDate()
Description copied from interface:XMPDateTimeThis flag is set either by parsing or by setting year, month or day.- Specified by:
hasDatein interfaceXMPDateTime- Returns:
- Returns true if the XMPDateTime object has a date portion.
- See Also:
XMPDateTime.hasDate()
-
hasTime
public boolean hasTime()
Description copied from interface:XMPDateTimeThis flag is set either by parsing or by setting hours, minutes, seconds or milliseconds.- Specified by:
hasTimein interfaceXMPDateTime- Returns:
- Returns true if the XMPDateTime object has a time portion.
- See Also:
XMPDateTime.hasTime()
-
hasTimeZone
public boolean hasTimeZone()
Description copied from interface:XMPDateTimeThis flag is set either by parsing or by setting hours, minutes, seconds or milliseconds.- Specified by:
hasTimeZonein interfaceXMPDateTime- Returns:
- Returns true if the XMPDateTime object has a defined timezone.
- See Also:
XMPDateTime.hasTimeZone()
-
getCalendar
public Calendar getCalendar()
- Specified by:
getCalendarin 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:
XMPDateTime.getCalendar()
-
getISO8601String
public String getISO8601String()
- Specified by:
getISO8601Stringin interfaceXMPDateTime- Returns:
- Returns the ISO 8601 string representation of the date and time.
- See Also:
XMPDateTime.getISO8601String()
-
-