LocalDate

@Serializable(with = LocalDateSerializer)
class LocalDate


A date without a time-zone in the ISO-8601 calendar system, such as {@code 2007-12-03}. This is the default Kotlin type used to represent a Date GraphQL custom scalar in Firebase Data Connect.

Description (adapted from java.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 a LocalDate.

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 to java.time.LocalDate and kotlinx.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 its minSdkVersion to 26 or later, then this class will be marked as "deprecated" and eventually removed.

The java.time.LocalDate class was added in Android API 26 and should be used if it's available instead of this class. If java.time.LocalDate is available then kotlinx.datetime.LocalDate is a completely valid option as well, if it's desirable to take a dependency on https://github.com/Kotlin/kotlinx-datetime.

Alternately, if your application has its minSdkVersion set to a value less than 26, you can use "desugaring" (https://developer.android.com/studio/write/java8-support-table) to get access java.time.LocalDate class regardless of the API version used at runtime.

Using java.time.LocalDate and kotlinx.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 preferable java.time.LocalDate or kotlinx.datetime.LocalDate classes, add a dateClass entry in your connector.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 # or kotlinx.datetime.LocalDate

Safe for Concurrent Use

All methods and properties of FirebaseDataConnect 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 operator Boolean
equals(other: Any?)

Compares this object with another object for equality.

open Int

Calculates and returns the hash code for this object.

open String

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 new LocalDate instance with the given property values.

LocalDate

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

LocalDate

Creates and returns a kotlinx.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 of LocalDate and has the same values for year, month, and day as this object, respectively.

hashCode

open fun hashCode(): Int

Calculates and returns the hash code for this object.

The hash code is not 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 is not 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 is not checked or prevented by this class.

month

val monthInt

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

year

val yearInt

The year. The valid range is between 1583 and 9999, inclusive; however, this is not checked or prevented by this class. Values less than 1583 are not forbidden; however, their interpretation by the Data Connect backend is unspecified. See https://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 new LocalDate instance with the given property values.

toJavaLocalDate

fun LocalDate.toJavaLocalDate(): LocalDate

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

Be sure to only call this method if java.time.LocalDate is available; otherwise the behavior is undefined. If your application's minSdkVersion is greater than or equal to 26, or if you have configured "desugaring" (https://developer.android.com/studio/write/java8-support-table) then it is guaranteed to be available. Otherwise, check android.os.Build.VERSION.SDK_INT at runtime and verify that its value is at least android.os.Build.VERSION_CODES.O before calling this method.

toKotlinxLocalDate

fun LocalDate.toKotlinxLocalDate(): LocalDate

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

Be sure to only call this method if your application has a dependency on org.jetbrains.kotlinx:kotlinx-datetime; otherwise, the behavior of this method is undefined. If your minSdkVersion is less than 26 then you may also need to configure "desugaring" (https://developer.android.com/studio/write/java8-support-table).