Property

monthPattern

Source set: Android
val monthPattern =
        remember(locale) {
            val yearPattern = DateFormat.getBestDateTimePattern(locale, "y")
            // REVISED, SAFER HEURISTIC:
            // Check if the pattern contains any letter that isn't 'y'. This correctly
            // identifies linguistic markers like '年', '년', 'г', etc., while safely
            // ignoring spaces or simple punctuation.
            val useNumericMonth = yearPattern.any { it.isLetter() && it != 'y' }

            if (useNumericMonth) {
                "MM"
            } else {
                "MMM"
            }
        }
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: