Package org.gedcomx.date
Class GedcomxDateSimple
java.lang.Object
org.gedcomx.date.GedcomxDate
org.gedcomx.date.GedcomxDateSimple
- All Implemented Interfaces:
Comparable<GedcomxDate>
A Simple Date
- Author:
- John Clark.
-
Constructor Summary
ConstructorsConstructorDescriptionGedcomxDateSimple(String date) Instantiate a new Simple date based off of a formal date string. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(GedcomxDate other) Compares this GedcomxDateSimple object with either another GedcomxDateSimple object or a GedcomxDateApproximate object.getDay()Get the daygetHours()Get the hoursGet the minutesgetMonth()Get the monthGet the secondsgetType()Get the Date TypeGet the timezone hoursGet the timezone minutesgetYear()Get the yearbooleanWhether or not this date can be considered approximateOutput the formal string for this date
-
Constructor Details
-
GedcomxDateSimple
Instantiate a new Simple date based off of a formal date string.- Parameters:
date- The date
-
-
Method Details
-
getType
Get the Date Type- Specified by:
getTypein classGedcomxDate- Returns:
- The type
-
isApproximate
public boolean isApproximate()Whether or not this date can be considered approximate- Specified by:
isApproximatein classGedcomxDate- Returns:
- True if this is approximate
-
toFormalString
Output the formal string for this date- Specified by:
toFormalStringin classGedcomxDate- Returns:
- The formal date string
-
getYear
Get the year- Returns:
- The Year
-
getMonth
Get the month- Returns:
- The Month
-
getDay
Get the day- Returns:
- The Day
-
getHours
Get the hours- Returns:
- The Hours
-
getMinutes
Get the minutes- Returns:
- The Minutes
-
getSeconds
Get the seconds- Returns:
- The seconds
-
getTzHours
Get the timezone hours- Returns:
- The Timezone Hours
-
getTzMinutes
Get the timezone minutes- Returns:
- The Timezone Minutes
-
compareTo
Compares this GedcomxDateSimple object with either another GedcomxDateSimple object or a GedcomxDateApproximate object. Comparison is achieved by using an ISO 8601 date format using the populated temporal fields in this object amd the fields in the other object. If a field is null it defaults to a "0th" value. So in the case of the simplest date of only a year field value it would default to January 1 at midnight UTC of the given year. ISO 8601 conversion occurs for boththisandother. In other words, if there is missing field information it will reflect as the earliest possible ISO 8601 representation of the object to use in comparison.- Specified by:
compareToin interfaceComparable<GedcomxDate>- Overrides:
compareToin classGedcomxDate- Parameters:
other- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object
- Throws:
ClassCastException- if other is not of type GedcomxDateSimple or GedcomxDateApproximateNullPointerException- if other is null
-