formatNepaliDateByUnicodePattern

fun formatNepaliDateByUnicodePattern(unicodePattern: String, calendar: CustomCalendar, language: NepaliDatePickerLang = NepaliDatePickerLang.NEPALI): String(source)

Formats a Nepali date based on the specified Unicode pattern and language preferences.

Return

A string representing the formatted date and time according to the provided Unicode pattern and language preferences.

The function supports the following placeholders in the unicodePattern:

  • yyyy: Four-digit year (e.g., "2025" or "२०२५")

  • yy: Two-digit year (e.g., "25" or "२५")

  • MMMM: Full month name (e.g., "Baisakh" or "बैशाख")

  • MMM: Abbreviated month name (e.g., "Bai" or "बै")

  • MM: Two-digit month (e.g., "01" or "०१")

  • M: Month number, no padding (e.g., "1" or "१")

  • dd: Two-digit day of month (e.g., "04" or "०४")

  • d: Day of month, no padding (e.g., "4" or "४")

  • D: Day of the year (1–366) (e.g., "123" or "१२३")

  • w: Week of the year (e.g., "23" or "२३")

  • EEEE: Full weekday name (e.g., "Monday" or "सोमबार")

  • E: Medium weekday name (e.g., "Mon" or "सोम")

  • EEEEE: Short weekday name, if defined (e.g., "M" or "स")

  • ee: Two-digit day of week (e.g., "02" or "०२")

  • e: Day of week, no padding (e.g., "2" or "२")

Example usage:

val calendar = CustomCalendar(year = 2025, month = 5, dayOfMonth = 14, dayOfWeek = 3, ...)
val formattedDateTime = formatNepaliDateByUnicodePattern(
"yyyy-MM-dd EEEE",
calendar,
NepaliDatePickerLang.ENGLISH
)
// formattedDateTime: "2025-05-14 Tuesday"

Parameters

calendar

A CustomCalendar representing the date.

unicodePattern

A string specifying the pattern to use for formatting the date and time. The pattern supports various placeholders like "yyyy", "MM", "dd", "D", "E", "ee", etc.

language

The NepaliDatePickerLang specifying the language for formatting the date and time. Defaults to NepaliDatePickerLang.NEPALI, which uses Nepali month and weekday names.