Stay organized with collections
Save and categorize content based on your preferences.
DateSorter
open class DateSorter
Sorts dates into the following groups: Today Yesterday seven days ago one month ago older than a month ago
Summary
Constants |
static Int |
must be >= 3
|
Constants
DAY_COUNT
static val DAY_COUNT: Int
must be >= 3
Value: 5
Public constructors
DateSorter
DateSorter(context: Context!)
Parameters |
context |
Context!: Application context |
Public methods
getBoundary
open fun getBoundary(index: Int): Long
Parameters |
index |
Int: date bin index as returned by getIndex() |
Return |
Long |
date boundary at given index |
getIndex
open fun getIndex(time: Long): Int
Parameters |
time |
Long: time since the Epoch in milliseconds, such as that returned by Calendar.getTimeInMillis() |
Return |
Int |
an index from 0 to (DAY_COUNT - 1) that identifies which date bin this date belongs to |
getLabel
open fun getLabel(index: Int): String!
Parameters |
index |
Int: date bin index as returned by getIndex() |
Return |
String! |
string label suitable for display to user |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# DateSorter\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nDateSorter\n==========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/webkit/DateSorter \"View this page in Java\") \n\n```\nopen class DateSorter\n```\n\n|---|--------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.webkit.DateSorter](#) |\n\nSorts dates into the following groups: Today Yesterday seven days ago one month ago older than a month ago\n\nSummary\n-------\n\n| Constants ||\n|-----------------------------------------------------------------------------------|--------------------------------------------------|\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [DAY_COUNT](#DAY_COUNT:kotlin.Int) must be \\\u003e= 3 |\n\n| Public constructors ||\n|----------------------------------------------------------------------------------------------------------------|---|\n| [DateSorter](#DateSorter(android.content.Context))`(`context:` `[Context](../content/Context.html#)!`)` \u003cbr /\u003e |\n\n| Public methods ||\n|----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|\n| open [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | [getBoundary](#getBoundary(kotlin.Int))`(`index:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` \u003cbr /\u003e |\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getIndex](#getIndex(kotlin.Long))`(`time:` `[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)`)` \u003cbr /\u003e |\n| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [getLabel](#getLabel(kotlin.Int))`(`index:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` \u003cbr /\u003e |\n\nConstants\n---------\n\n### DAY_COUNT\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val DAY_COUNT: Int\n```\n\nmust be \\\u003e= 3 \n\n Value: 5\n\nPublic constructors\n-------------------\n\n### DateSorter\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nDateSorter(context: Context!)\n```\n\n| Parameters ||\n|-----------|-----------------------------------------------------------|\n| `context` | [Context](../content/Context.html#)!: Application context |\n\nPublic methods\n--------------\n\n### getBoundary\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getBoundary(index: Int): Long\n```\n\n| Parameters ||\n|---------|----------------------------------------------------------------------------------------------------------------------|\n| `index` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): date bin index as returned by getIndex() |\n\n| Return ||\n|------------------------------------------------------------------------------|------------------------------|\n| [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | date boundary at given index |\n\n### getIndex\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getIndex(time: Long): Int\n```\n\n| Parameters ||\n|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `time` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): time since the Epoch in milliseconds, such as that returned by Calendar.getTimeInMillis() |\n\n| Return ||\n|----------------------------------------------------------------------------|----------------------------------------------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | an index from 0 to (DAY_COUNT - 1) that identifies which date bin this date belongs to |\n\n### getLabel\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getLabel(index: Int): String!\n```\n\n| Parameters ||\n|---------|----------------------------------------------------------------------------------------------------------------------|\n| `index` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): date bin index as returned by getIndex() |\n\n| Return ||\n|-----------------------------------------------------------------------------------|-------------------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | string label suitable for display to user |"]]