savvisingh / DateRangePicker

Date Range Picker is a Calendar Picker View to show a Customized Date Range Picker with improved UI and functionality to add subtitles to the dates
Apache License 2.0
784 stars 160 forks source link

Not correct month names in Russian #32

Closed Uselesslav closed 6 years ago

Uselesslav commented 6 years ago

Январь - January Февраль - February Март - March Апрель - April Май - May Июнь - June Июль - July Август - August Сентябрь - September Октябрь - October Ноябрь - November Декабрь - December

CoolMind commented 6 years ago

In Kotlin.

Initialization:

calendar.init(minDate, maxDate, MonthFormat("MMMM yyyy", Locale.getDefault()))
    .inMode(CalendarPickerView.SelectionMode.RANGE)

Class MonthFormat:

class MonthFormat(pattern: String, locale: Locale) : SimpleDateFormat(pattern, locale) {

    private val months = arrayOf(
        "Январь", "Февраль", "Март", "Апрель", "Май", "Июнь",
        "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь")

    override fun format(date: Date?, toAppendTo: StringBuffer?, pos: FieldPosition?): StringBuffer {
        val sb = StringBuffer()
        calendar.time = date
        sb.append(months[calendar.get(Calendar.MONTH)])
            .append(" ")
            .append(calendar.get(Calendar.YEAR))
        return sb
    }
}