Skip to content

Commit

Permalink
Update Utils.kt and DateHelper.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
biplab1 committed Jan 14, 2025
1 parent a446e95 commit 256a2f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,9 @@ object DateHelper {
* "dd-MM-yyyy" is the format of the date picker.
*/
val formattedShortDate = currentDate.format(shortMonthFormat)

fun getMonth(month: Int): String {
require(month in 1..12) { "Month should be between 1 and 12" }
return Month.entries[month - 1].name.lowercase().replaceFirstChar { it.uppercase() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@ object Utils {
return formString.toString()
}

fun formatTransactionType(type: String?): String {
val builder = StringBuilder()
try {
type?.lowercase()?.split("_")?.forEach { str ->
builder.append(
str[0].uppercaseChar() + str.substring(1),
).append(" ")
fun formatTransactionType(type: String?): String =
type?.lowercase()
?.split("_")
?.joinToString(" ") { word ->
word.replaceFirstChar { it.uppercase() }
}
} catch (_: Exception) {
}
return builder.toString().trim()
}
?.trim()
?: ""
}

0 comments on commit 256a2f4

Please sign in to comment.