Skip to content

[MaterialDatePicker] Choose different Calendar API and define custom DateTime Format #2481

@IamMitsuo

Description

@IamMitsuo

Is your feature request related to a problem? Please describe.
The current issue is that MaterialDatePicker is using java.util.Calendar (Java 7) as an underlying API to get UTC epoch millisecond and datetime format, and convert it to Month object where year property is retrieved from Calendar.get(Calendar.YEAR). This causes date string to always show year in Christian Era and/or B.C.E. As a Thai user, most of Thai are familiar with Buddhist Calendar (Buddhist year = Christian year + 543 e.g. 2021 = 2564), so elder users tend to not know which Christian year of their birthdate.

Describe the solution you'd like

  • It would be great if we can customize or delegate how Month object is created, so it does not limit to only java.util.Calendar API, but open to java.time.chrono.ThaiBuddhistDate or org.threeten.bp.chrono.ThaiBuddhistDate (Threeten ABP).
MaterialDatePicker.Builder
    .datePicker()
    .setCustomMonth(CustomMonth())
open class CustomMonth(private val thaiBuddhistDate: ThaiBuddhistDate) : Month() {
     
     override fun getYear(): Int {
          return thaiBuddhistDate.getLong(ChronoField.YEAR).toInt()
     }
}
  • Moreover, a custom date format should be a feature of MaterialDatePicker as well.

Additional context
Example screenshots from another library (ThaiDateTimePicker - very old library)
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions