library / org.akop.kotx.types / MutableDateTime

MutableDateTime

class MutableDateTime : DateTime

MutableDateTime is a mutable subclass of DateTime.

See DateTime for specific details.

Constructors

<init>

MutableDateTime(timeZoneId: String? = null)

Constructs a new MutableDateTime object using specified time zone.

MutableDateTime(calendar: Calendar)

Constructs a new MutableDateTime object based on specified calendar instance.

MutableDateTime(dateTime: DateTime)

Constructs a new MutableDateTime object based on specified dateTime instance.

MutableDateTime(millis: Long, timeZoneId: String? = null)

Constructs a new MutableDateTime object with specified number of milliseconds since epoch.

MutableDateTime(year: Int, month: Int, day: Int, hours: Int = 0, minutes: Int = 0, seconds: Int = 0, milliseconds: Int = 0, timeZoneId: String? = null)

Constructs a new MutableDateTime object with specified year, month and day, and optionally hours, minutes, seconds and milliseconds.

Properties

day

var day: Int

Gets/sets day of month - first day is 1.

dayOfWeek

var dayOfWeek: Int

Gets/sets day of week - constants are identical to those used by Calendar.

hour

var hour: Int

Gets/sets hour within day - between 0 to 23.

milli

var milli: Int

Gets/sets millisecond within second.

millis

var millis: Long

Gets/sets time in milliseconds since epoch.

minute

var minute: Int

Gets/sets minute within hour.

month

var month: Int

Gets/sets month of year - first month is 1.

second

var second: Int

Gets/sets second within minute.

timeZoneId

var timeZoneId: String

Gets/sets the timezone id for the instance.

year

var year: Int

Gets/sets year.

Functions

addDays

fun addDays(value: Int): Unit

Updates MutableDateTime instance by adding value to day component. Value may be negative.

addHours

fun addHours(value: Int): Unit

Updates MutableDateTime instance by adding value to hour component. Value may be negative.

addMillis

fun addMillis(value: Int): Unit

Updates MutableDateTime instance by adding value to millisecond component. Value may be negative.

addMinutes

fun addMinutes(value: Int): Unit

Updates MutableDateTime instance by adding value to minute component. Value may be negative.

addMonths

fun addMonths(value: Int): Unit

Updates MutableDateTime instance by adding value to month component. Value may be negative.

addSeconds

fun addSeconds(value: Int): Unit

Updates MutableDateTime instance by adding value to second component. Value may be negative.

addYears

fun addYears(value: Int): Unit

Updates MutableDateTime instance by adding value to year component. Value may be negative.

toImmutable

fun toImmutable(): DateTime

Returns an immutable version of the instance.

toMutable

fun toMutable(): MutableDateTime

Because MutableDateTime itself is mutable, returns the receiver instance.

truncateTime

fun truncateTime(): Unit

Updates MutableDateTime instance by setting hour, minute, second and millisecond components to zero.

Inherited Functions

addedDays

fun addedDays(value: Int): DateTime

Returns an instance of DateTime resulting from adding value to day component. Value may be negative.

addedHours

fun addedHours(value: Int): DateTime

Returns an instance of DateTime resulting from adding value to hour component. Value may be negative.

addedMillis

fun addedMillis(value: Int): DateTime

Returns an instance of DateTime resulting from adding value to millisecond component. Value may be negative.

addedMinutes

fun addedMinutes(value: Int): DateTime

Returns an instance of DateTime resulting from adding value to minute component. Value may be negative.

addedMonths

fun addedMonths(value: Int): DateTime

Returns an instance of DateTime resulting from adding value to month component. Value may be negative.

addedSeconds

fun addedSeconds(value: Int): DateTime

Returns an instance of DateTime resulting from adding value to second component. Value may be negative.

addedYears

fun addedYears(value: Int): DateTime

Returns an instance of DateTime resulting from adding value to year component. Value may be negative.

after

infix fun after(other: DateTime): Boolean
infix fun after(other: Calendar): Boolean

Returns true if receiver falls after other.

infix fun after(other: Long): Boolean

Returns true if receiver falls after other - given in milliseconds since epoch.

before

infix fun before(other: DateTime): Boolean
infix fun before(other: Calendar): Boolean

Returns true if receiver falls before other.

infix fun before(other: Long): Boolean

Returns true if receiver falls before other - given in milliseconds since epoch.

compareTo

fun compareTo(other: Calendar): Int

Returns -1, 0, 1 if the instance is less than, equal to, or greater than specified Calendar instance, respectively.

fun compareTo(other: Long): Int

Returns -1, 0, 1 if the instance is less than, equal to, or greater than specified number of milliseconds from epoch, respectively.

open fun compareTo(other: DateTime): Int

Returns -1, 0, 1 if the instance is less than, equal to, or greater than other instance, respectively.

component1

operator fun component1(): Int

Returns year as the first component.

component2

operator fun component2(): Int

Returns month as the second component.

component3

operator fun component3(): Int

Returns day of month as the third component.

component4

operator fun component4(): Int

Returns hour of day as the fourth component.

component5

operator fun component5(): Int

Returns minute of hour as the fifth component.

component6

operator fun component6(): Int

Returns second of minute as the sixth component.

component7

operator fun component7(): Int

Returns millisecond of minute as the seventh component.

describeContents

open fun describeContents(): Int

Returns zero.

equals

open fun equals(other: Any?): Boolean

Returns true if the specified DateTime, Calendar, or Long (number of milliseconds from epoch) is equal to instance.

hashCode

open fun hashCode(): Int

Returns hash code of the instance - which is equal to its Calendar's hashCode value.

on

infix fun on(other: DateTime): Boolean
infix fun on(other: Calendar): Boolean
infix fun on(other: Long): Boolean

Returns true if receiver represents the same time as other.

onOrAfter

infix fun onOrAfter(other: DateTime): Boolean
infix fun onOrAfter(other: Calendar): Boolean

Returns true if receiver falls on or after other.

infix fun onOrAfter(other: Long): Boolean

Returns true if receiver falls on or after other - given in milliseconds since epoch.

onOrBefore

infix fun onOrBefore(other: DateTime): Boolean
infix fun onOrBefore(other: Calendar): Boolean

Returns true if receiver falls on or before other.

infix fun onOrBefore(other: Long): Boolean

Returns true if receiver falls on or before other - given in milliseconds since epoch.

toCalendar

fun toCalendar(): Calendar

Returns a clone of the Calendar object.

toString

fun toString(format: String, timeZoneId: String? = null): String

Returns a string representation of DateTime instance in specified format and optionally, time zone.

fun toString(format: DateFormat): String

Returns a string representation of DateTime instance in specified DateFormat.

open fun toString(): String

Returns a string representation of DateTime instance in RFC-3339 format, in UTC - e.g. "1983-07-15T08:00:59Z".

toTimeZone

fun toTimeZone(timeZoneId: String?): DateTime

Returns the DateTime instance in specified time zone.

toUTC

fun toUTC(): DateTime

Returns UTC representation of the DateTime instance.

truncatedTime

fun truncatedTime(): DateTime

Returns an instance of DateTime with hour, minute, second and millisecond components set to zero.

writeToParcel

open fun writeToParcel(dest: Parcel, flags: Int): Unit

Implements Parcelable.writeToParcel by writing number of milliseconds since epoch and time zone id.

Companion Object Properties

CREATOR

val CREATOR: Creator<MutableDateTime>

Implementation of Parcelable.Creator.

now

val now: MutableDateTime

Returns MutableDateTime instance representing current time and date.

today

val today: MutableDateTime

Returns MutableDateTime instance representing date. Time components will be set to zero.

Companion Object Functions

parse

fun parse(string: String, format: DateFormat): MutableDateTime

Parses string in specified format and returns a MutableDateTime instance.

tryParse

fun tryParse(string: String, format: DateFormat): MutableDateTime?

Parses string in specified format and returns a MutableDateTime instance, or null if parsing fails.