Skip to content

Instantly share code, notes, and snippets.

@Dinoy-Raj
Created March 18, 2024 12:19
Show Gist options
  • Save Dinoy-Raj/9e2087b3d0a2b620d37be37dc65e8c6a to your computer and use it in GitHub Desktop.
Save Dinoy-Raj/9e2087b3d0a2b620d37be37dc65e8c6a to your computer and use it in GitHub Desktop.
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
fun List<String?>?.formatter(type: ListFormatter.Type, width: Width): String {
var formattedValue = ""
try {
ListFormatter.getInstance()
val formatter = ListFormatter.getInstance(Locale.getDefault(), type, width)
formattedValue = formatter.format(this)
} catch (e: Exception) {
Log.d("ListFormatter", "error in formatting list")
}
return formattedValue
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment