public final class PartialDate extends 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 reduced accuracy date is a date where the "lesser" components are missing. For example, "12:30" is reduced accuracy because the "seconds" component is missing.
PartialDate date = PartialDate.builder().hour(12).minute(30).build();
A truncated date is a date where the "greater" components are missing. For example, "April 20" is truncated because the "year" component is missing.
PartialDate date = PartialDate.builder().month(4).date(20).build();
Modifier and Type | Class and Description |
---|---|
static class |
PartialDate.Builder
Constructs instances of the
PartialDate class. |
Modifier and Type | Method and Description |
---|---|
static PartialDate.Builder |
builder()
Creates a builder object.
|
static PartialDate.Builder |
builder(PartialDate orig)
Creates a builder object.
|
boolean |
equals(Object obj) |
Integer |
getDate()
Gets the date component.
|
Integer |
getHour()
Gets the hour component.
|
Integer |
getMinute()
Gets the minute component.
|
Integer |
getMonth()
Gets the month component.
|
Integer |
getSecond()
Gets the second component.
|
ZoneOffset |
getUtcOffset()
Gets the UTC offset.
|
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 |
parse(String string)
Parses a partial date from a string.
|
String |
toISO8601(boolean extended)
Converts this partial date to its ISO 8601 representation.
|
String |
toString() |
public static PartialDate.Builder builder()
public static PartialDate.Builder builder(PartialDate orig)
orig
- the object to copypublic static PartialDate parse(String string)
string
- the string (e.g. "--0420T15")IllegalArgumentException
- if there's a problem parsing the date
stringpublic Integer getYear()
public Integer getMonth()
public Integer getDate()
public Integer getHour()
public Integer getMinute()
public Integer getSecond()
public ZoneOffset getUtcOffset()
public boolean hasDateComponent()
public boolean hasTimeComponent()
public String toISO8601(boolean extended)
extended
- true to use extended format, false to use basicIllegalStateException
- if an ISO 8601 representation of the date
cannot be created because the date's components are invalid. This will
not happen if the partial date is constructed using the
builder()
methodCopyright © 2012–2023 Michael Angstadt. All rights reserved.