public final class PartialDate
extends java.lang.Object
Represents a date in which some of the components are missing. This is used to represent reduced accuracy and truncated dates, as defined in ISO8601.
A truncated date is a date where the "lesser" components are missing. For example, "12:30" is truncated because the "seconds" component is missing.
PartialDate date = PartialDate.time(12, 30, null);
A reduced accuracy date is a date where the "greater" components are missing. For example, "April 20" is reduced accuracy because the "year" component is missing.
PartialDate date = PartialDate.date(null, 4, 20);
Constructor and Description |
---|
PartialDate(java.lang.Integer year,
java.lang.Integer month,
java.lang.Integer date,
java.lang.Integer hour,
java.lang.Integer minute,
java.lang.Integer second,
UtcOffset offset)
Creates a new partial date.
|
PartialDate(java.lang.String string)
Parses a partial date from a string.
|
Modifier and Type | Method and Description |
---|---|
static PartialDate |
date(java.lang.Integer year,
java.lang.Integer month,
java.lang.Integer date)
Creates a partial date containing only date components.
|
static PartialDate |
dateTime(java.lang.Integer year,
java.lang.Integer month,
java.lang.Integer date,
java.lang.Integer hour,
java.lang.Integer minute,
java.lang.Integer second)
Creates a partial date containing date and time components, without a
timezone.
|
static PartialDate |
dateTime(java.lang.Integer year,
java.lang.Integer month,
java.lang.Integer date,
java.lang.Integer hour,
java.lang.Integer minute,
java.lang.Integer second,
UtcOffset offset)
Creates a partial date containing date and time components.
|
boolean |
equals(java.lang.Object obj) |
java.lang.Integer |
getDate()
Gets the date component.
|
java.lang.Integer |
getHour()
Gets the hour component.
|
java.lang.Integer |
getMinute()
Gets the minute component.
|
java.lang.Integer |
getMonth()
Gets the month component.
|
java.lang.Integer |
getSecond()
Gets the second component.
|
java.lang.Integer[] |
getTimezone()
Gets the timezone component.
|
java.lang.Integer |
getYear()
Gets the year component.
|
boolean |
hasDateComponent()
Determines if there are any date components.
|
int |
hashCode() |
boolean |
hasTimeComponent()
Determines if there are any time components.
|
static PartialDate |
time(java.lang.Integer hour,
java.lang.Integer minute,
java.lang.Integer second)
Creates a partial date containing only time components.
|
static PartialDate |
time(java.lang.Integer hour,
java.lang.Integer minute,
java.lang.Integer second,
UtcOffset offset)
Creates a partial date containing only time components.
|
java.lang.String |
toDateAndOrTime(boolean extended)
Converts this partial date to its ISO 8601 representation.
|
java.lang.String |
toString() |
public PartialDate(java.lang.Integer year, java.lang.Integer month, java.lang.Integer date, java.lang.Integer hour, java.lang.Integer minute, java.lang.Integer second, UtcOffset offset)
Creates a new partial date.
The following combinations are not allowed and will result in an
IllegalArgumentException
being thrown:
year
- the year or null to excludemonth
- the month or null to excludedate
- the day of the month or null to excludehour
- the hour or null to excludeminute
- the minute or null to excludesecond
- the second or null to excludeoffset
- the UTC offset or null to excludejava.lang.IllegalArgumentException
- if an invalid combination is entered or
a component value is invalid (e.g. a negative minute)public PartialDate(java.lang.String string)
string
- the string (e.g. "--0420T15")public static PartialDate date(java.lang.Integer year, java.lang.Integer month, java.lang.Integer date)
Creates a partial date containing only date components.
The following combinations are not allowed and will result in an
IllegalArgumentException
being thrown:
year
- the year or null to excludemonth
- the month or null to excludedate
- the day of the month or null to excludejava.lang.IllegalArgumentException
- if an invalid combination is entered or
a component value is invalid (e.g. a negative month)public static PartialDate time(java.lang.Integer hour, java.lang.Integer minute, java.lang.Integer second)
Creates a partial date containing only time components.
The following combinations are not allowed and will result in an
IllegalArgumentException
being thrown:
hour
- the hour or null to excludeminute
- the minute or null to excludesecond
- the second or null to excludejava.lang.IllegalArgumentException
- if an invalid combination is entered or
a component value is invalid (e.g. a negative minute)public static PartialDate time(java.lang.Integer hour, java.lang.Integer minute, java.lang.Integer second, UtcOffset offset)
Creates a partial date containing only time components.
The following combinations are not allowed and will result in an
IllegalArgumentException
being thrown:
hour
- the hour or null to excludeminute
- the minute or null to excludesecond
- the second or null to excludeoffset
- the UTC offset or null to excludejava.lang.IllegalArgumentException
- if an invalid combination is entered or
a component value is invalid (e.g. a negative minute)public static PartialDate dateTime(java.lang.Integer year, java.lang.Integer month, java.lang.Integer date, java.lang.Integer hour, java.lang.Integer minute, java.lang.Integer second)
Creates a partial date containing date and time components, without a timezone.
The following combinations are not allowed and will result in an
IllegalArgumentException
being thrown:
year
- the year or null to excludemonth
- the month or null to excludedate
- the day of the month or null to excludehour
- the hour or null to excludeminute
- the minute or null to excludesecond
- the second or null to excludejava.lang.IllegalArgumentException
- if an invalid combination is entered or
a component value is invalid (e.g. a negative minute)public static PartialDate dateTime(java.lang.Integer year, java.lang.Integer month, java.lang.Integer date, java.lang.Integer hour, java.lang.Integer minute, java.lang.Integer second, UtcOffset offset)
Creates a partial date containing date and time components.
The following combinations are not allowed and will result in an
IllegalArgumentException
being thrown:
year
- the year or null to excludemonth
- the month or null to excludedate
- the day of the month or null to excludehour
- the hour or null to excludeminute
- the minute or null to excludesecond
- the second or null to excludeoffset
- the UTC offset or null to excludejava.lang.IllegalArgumentException
- if an invalid combination is entered or
a component value is invalid (e.g. a negative minute)public java.lang.Integer getYear()
public java.lang.Integer getMonth()
public java.lang.Integer getDate()
public java.lang.Integer getHour()
public java.lang.Integer getMinute()
public java.lang.Integer getSecond()
public java.lang.Integer[] getTimezone()
public boolean hasDateComponent()
public boolean hasTimeComponent()
public java.lang.String toDateAndOrTime(boolean extended)
extended
- true to use extended format, false to use basicpublic int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
This software is published under the BSD license. Copyright © 2003-${build.year}, CRIXP AG, Switzerland, All rights reserved. Use is subject to license terms.