LocalDate

@Serializable(with = LocalDateSerializer)
classLocalDate


A date without a time-zone in the ISO-8601 calendar system, such as2007-12-03. This is the default Kotlin type used to represent aDate GraphQL custom scalar in Firebase Data Connect.

Description (adapted fromjava.time.LocalDate)

LocalDate is an immutable date-time object that represents a date, often viewed as year-month-day. For example, the value "2nd October 2007" can be stored in aLocalDate.

This class does not store or represent a time or time-zone. Instead, it is a description of the date, as used for birthdays. It cannot represent an instant on the time-line without additional information such as an offset or time-zone.

Relationship tojava.time.LocalDate andkotlinx.datetime.LocalDate

This class exists solely to fill the gap for a "day-month-year" data type in Android API versions less than 26. When the Firebase Android SDK updates itsminSdkVersion to 26 or later, then this class will be marked as "deprecated" and eventually removed.

Thejava.time.LocalDate class was added in Android API 26 and should be used if it's available instead of this class. Ifjava.time.LocalDate is available thenkotlinx.datetime.LocalDate is a completely valid option as well, if it's desirable to take a dependency onkotlinx-datetime.

Alternately, if your application has itsminSdkVersion set to a valueless than 26, you can use"desugaring" to get accessjava.time.LocalDate class regardless of the API version used at runtime.

Usingjava.time.LocalDate andkotlinx.datetime.LocalDate in code generation.

By default, the Firebase Data Connect code generation will use this class when generating code for Kotlin. If, however, you want to use the preferablejava.time.LocalDate orkotlinx.datetime.LocalDate classes, add adateClass entry in yourconnector.yaml set to the fully-qualified class name that you'd like to use. For example,

connectorId:demo
authMode
:PUBLIC
generate
:
kotlinSdk:
outputDir:../../.generated/demo
dateClass:java.time.LocalDate#orkotlinx.datetime.LocalDate

Safe for concurrent use

All methods and properties ofLocalDate are thread-safe and may be safely called and/or accessed concurrently from multiple threads and/or coroutines.

Summary

Public constructors

LocalDate(year: Int, month: Int, day: Int)

Public functions

open operatorBoolean
equals(other: Any?)

Compares this object with another object for equality.

openInt

Calculates and returns the hash code for this object.

openString

Returns a string representation of this object, useful for debugging.

Public properties

Int

The day of the month.

Int

The month.

Int

The year.

Extension functions

LocalDate
LocalDate.copy(year: Int, month: Int, day: Int)

Creates and returns a newLocalDate instance with the given property values.

LocalDate

Creates and returns ajava.time.LocalDate object that represents the same date as this object.

LocalDate

Creates and returns akotlinx.datetime.LocalDate object that represents the same date as this object.

Public constructors

LocalDate

LocalDate(year: Int, month: Int, day: Int)

Public functions

equals

open operator fun equals(other: Any?): Boolean

Compares this object with another object for equality.

Parameters
other: Any?

The object to compare to this for equality.

Returns
Boolean

true if, and only if, the other object is an instance ofLocalDate and has the same values foryear,month, andday as this object, respectively.

hashCode

open fun hashCode(): Int

Calculates and returns the hash code for this object.

The hash code isnot guaranteed to be stable across application restarts.

Returns
Int

the hash code for this object, that incorporates the values of this object's public properties.

toString

open fun toString(): String

Returns a string representation of this object, useful for debugging.

The string representation isnot guaranteed to be stable and may change without notice at any time. Therefore, the only recommended usage of the returned string is debugging and/or logging. Namely, parsing the returned string or storing the returned string in non-volatile storage should generally be avoided in order to be robust in case that the string representation changes.

Returns
String

a string representation of this object, which includes the class name and the values of all public properties.

Public properties

day

val dayInt

The day of the month. The valid range is between 1 and 31, inclusive; however, this isnot checked or enforced by this class.

month

val monthInt

The month. The valid range is between 1 and 12, inclusive; however, this isnot checked or enforced by this class.

year

val yearInt

The year. The valid range is between 1583 and 9999, inclusive; however, this isnot checked or enforced by this class. Values less than 1583 are not strictly forbidden; however, their interpretation by the Data Connect backend is unspecified. Seehttps://en.wikipedia.org/wiki/ISO_8601#Years for more details.

Extension functions

copy

fun LocalDate.copy(year: Int = this.year, month: Int = this.month, day: Int = this.day): LocalDate

Creates and returns a newLocalDate instance with the given property values.

toJavaLocalDate

fun LocalDate.toJavaLocalDate(): LocalDate

Creates and returns ajava.time.LocalDate object that represents the same date as this object.

Be sure toonly call this method ifjava.time.LocalDate is available; otherwise the behavior is undefined. If your application'sminSdkVersion is greater than or equal to26, or if you have configured"desugaring" then it is guaranteed to be available. Otherwise, checkandroid.os.Build.VERSION.SDK_INT at runtime and verify that its value is at leastandroid.os.Build.VERSION_CODES.O before calling this method.

toKotlinxLocalDate

fun LocalDate.toKotlinxLocalDate(): LocalDate

Creates and returns akotlinx.datetime.LocalDate object that represents the same date as this object.

Be sure toonly call this method if your application has a dependency onorg.jetbrains.kotlinx:kotlinx-datetime; otherwise, the behavior of this method is undefined. If yourminSdkVersion is less than26 then youmay also need to configure"desugaring".

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-10-09 UTC.