Class TimeValueImpl
- All Implemented Interfaces:
org.wikidata.wdtk.datamodel.interfaces.TimeValue,org.wikidata.wdtk.datamodel.interfaces.Value
public class TimeValueImpl
extends java.lang.Object
implements org.wikidata.wdtk.datamodel.interfaces.TimeValue
Time values represent points and intervals in time, and additional information about their
format. Information includes a specific time point, information about its precision, and the
preferred calendar model and timezone (for display). Moreover, time values can describe some
uncertainty regarding the exact position in time. This is achieved by tolerance values that
specify how much before or after the
given time point an event might have occurred.
Time points cannot describe durations (which are quantities), recurring events ("1st of May"), or time spans ( "He reigned from 1697 to 1706, i.e., during every moment of that time span" ). Intervals expressed by times always encode uncertainty ("He died in the year 546 BCE, i.e., in some moment within that interval").
The main time point of the value generally refers to the proleptic Gregorian calendar. However, if dates are imprecise (like "Jan 1512" or even "1200") then one cannot convert this reliably and Wikidata will just keep the value as entered.
"Y0K issue": Neither the Gregorian nor the Julian calendar assume a year 0, i.e., the year 1 BCE was followed by 1 CE in these calendars. See http://en.wikipedia.org/wiki/Year_zero. Wikibase internally uses the year 0. This is the same as ISO-8601, where 1 BCE is represented as "0000". However, note that XML Schema dates (1.0 and 2.0) do not have a year 0, so in their case 1BCE is represented as "-1". Understanding the difference is relevant for computing leap years, for computing temporal intervals, and for exporting data.
Timezone information is to be given in the form of a positive or negative offset with respect
to UTC, measured in minutes. This information specifies the timezone that the time should be
displayed in when shown to a user. The recorded time point is in UTC, so timezone can be ignored
for comparing values. See getTimezoneOffset().
- Author:
- Markus Kroetzsch
-
Field Summary
Fields inherited from interface org.wikidata.wdtk.datamodel.interfaces.TimeValue
CM_GREGORIAN_PRO, CM_JULIAN_PRO, PREC_100KY, PREC_100MY, PREC_100Y, PREC_10KY, PREC_10MY, PREC_1GY, PREC_1KY, PREC_1MY, PREC_DAY, PREC_DECADE, PREC_HOUR, PREC_MINUTE, PREC_MONTH, PREC_SECOND, PREC_YEAR -
Constructor Summary
Constructors Constructor Description TimeValueImpl()TimeValueImpl(long year)TimeValueImpl(long year, byte month, byte day)TimeValueImpl(long year, byte month, byte day, byte hour, byte minute, byte second, byte precision, int beforeTolerance, int afterTolerance, int timezoneOffset, java.lang.String preferredCalendarModel) -
Method Summary
Modifier and Type Method Description <T> Taccept(org.wikidata.wdtk.datamodel.interfaces.ValueVisitor<T> valueVisitor)intgetAfterTolerance()intgetBeforeTolerance()bytegetDay()bytegetHour()bytegetMinute()bytegetMonth()bytegetPrecision()java.lang.StringgetPreferredCalendarModel()org.wikidata.wdtk.datamodel.interfaces.ItemIdValuegetPreferredCalendarModelItemId()bytegetSecond()intgetTimezoneOffset()longgetYear()voidsetAfterTolerance(int afterTolerance)voidsetBeforeTolerance(int beforeTolerance)voidsetDay(byte day)voidsetHour(byte hour)voidsetMinute(byte minute)voidsetMonth(byte month)voidsetPrecision(byte precision)voidsetPreferredCalendarModel(java.lang.String preferredCalendarModel)voidsetSecond(byte second)voidsetTimezoneOffset(int timezoneOffset)voidsetYear(long year)org.wikidata.wdtk.datamodel.interfaces.TimeValuetoGregorian()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
TimeValueImpl
public TimeValueImpl() -
TimeValueImpl
public TimeValueImpl(long year, byte month, byte day, byte hour, byte minute, byte second, byte precision, int beforeTolerance, int afterTolerance, int timezoneOffset, java.lang.String preferredCalendarModel) -
TimeValueImpl
public TimeValueImpl(long year) -
TimeValueImpl
public TimeValueImpl(long year, byte month, byte day)
-
-
Method Details
-
accept
public <T> T accept(org.wikidata.wdtk.datamodel.interfaces.ValueVisitor<T> valueVisitor)- Specified by:
acceptin interfaceorg.wikidata.wdtk.datamodel.interfaces.Value
-
setAfterTolerance
public void setAfterTolerance(int afterTolerance) -
getAfterTolerance
public int getAfterTolerance()- Specified by:
getAfterTolerancein interfaceorg.wikidata.wdtk.datamodel.interfaces.TimeValue
-
setBeforeTolerance
public void setBeforeTolerance(int beforeTolerance) -
getBeforeTolerance
public int getBeforeTolerance()- Specified by:
getBeforeTolerancein interfaceorg.wikidata.wdtk.datamodel.interfaces.TimeValue
-
setPreferredCalendarModel
public void setPreferredCalendarModel(java.lang.String preferredCalendarModel) -
getDay
public byte getDay()- Specified by:
getDayin interfaceorg.wikidata.wdtk.datamodel.interfaces.TimeValue
-
setDay
public void setDay(byte day) -
getHour
public byte getHour()- Specified by:
getHourin interfaceorg.wikidata.wdtk.datamodel.interfaces.TimeValue
-
setHour
public void setHour(byte hour) -
getMinute
public byte getMinute()- Specified by:
getMinutein interfaceorg.wikidata.wdtk.datamodel.interfaces.TimeValue
-
setMinute
public void setMinute(byte minute) -
getMonth
public byte getMonth()- Specified by:
getMonthin interfaceorg.wikidata.wdtk.datamodel.interfaces.TimeValue
-
setMonth
public void setMonth(byte month) -
getPrecision
public byte getPrecision()- Specified by:
getPrecisionin interfaceorg.wikidata.wdtk.datamodel.interfaces.TimeValue
-
setPrecision
public void setPrecision(byte precision) -
getPreferredCalendarModel
public java.lang.String getPreferredCalendarModel()- Specified by:
getPreferredCalendarModelin interfaceorg.wikidata.wdtk.datamodel.interfaces.TimeValue
-
getPreferredCalendarModelItemId
public org.wikidata.wdtk.datamodel.interfaces.ItemIdValue getPreferredCalendarModelItemId()- Specified by:
getPreferredCalendarModelItemIdin interfaceorg.wikidata.wdtk.datamodel.interfaces.TimeValue
-
getSecond
public byte getSecond()- Specified by:
getSecondin interfaceorg.wikidata.wdtk.datamodel.interfaces.TimeValue
-
setSecond
public void setSecond(byte second) -
setTimezoneOffset
public void setTimezoneOffset(int timezoneOffset) -
getTimezoneOffset
public int getTimezoneOffset()- Specified by:
getTimezoneOffsetin interfaceorg.wikidata.wdtk.datamodel.interfaces.TimeValue
-
getYear
public long getYear()- Specified by:
getYearin interfaceorg.wikidata.wdtk.datamodel.interfaces.TimeValue
-
setYear
public void setYear(long year) -
toGregorian
public org.wikidata.wdtk.datamodel.interfaces.TimeValue toGregorian()- Specified by:
toGregorianin interfaceorg.wikidata.wdtk.datamodel.interfaces.TimeValue
-