LocalDate

public abstract class LocalDate implements Parcelable, Comparable


Represents a local date with year, month, and day.

This class is based on the java.time.LocalDate class (available on SDK 26 and higher).

Summary

Public constructors

Public methods

int
compareTo(LocalDate dateToCompare)
abstract @IntRange(from = 1, to = 31) int

Returns the day field.

abstract @IntRange(from = 1, to = 12) int

Returns the month field.

abstract int

Returns the year field.

static LocalDate
newInstance(
    int year,
    @IntRange(from = 1, to = 12) int month,
    @IntRange(from = 1, to = 31) int day
)

Returns a LocalDate instance given the year, month, and day.

final String

Outputs this date as a String in YYYY-MM-DD format, such as 2007-12-31.

Inherited Constants

From android.os.Parcelable
static final int
static final int
static final int
static final int

Inherited methods

From android.os.Parcelable
abstract int
int
abstract void
writeToParcel(Parcel p, int p1)

Public constructors

LocalDate

public LocalDate()

Public methods

compareTo

public int compareTo(LocalDate dateToCompare)

getDay

public abstract @IntRange(from = 1, to = 31) int getDay()

Returns the day field.

getMonth

public abstract @IntRange(from = 1, to = 12) int getMonth()

Returns the month field.

getYear

public abstract int getYear()

Returns the year field.

newInstance

public static LocalDate newInstance(
    int year,
    @IntRange(from = 1, to = 12) int month,
    @IntRange(from = 1, to = 31) int day
)

Returns a LocalDate instance given the year, month, and day.

Throws
java.lang.IllegalArgumentException

If parameters are not within range: 1 <= month<= 12, 1 <= day<= 31, or if the day is not valid for the given month and year.

toString

public final String toString()

Outputs this date as a String in YYYY-MM-DD format, such as 2007-12-31.

Returns
String

A string representation of this date.