fun formatDateTime(value: String?, format: String = "yyyy-MM-dd HH:mm"): String {
if (TextUtils.isEmpty(value)) return ""
return try {
//implementation 'joda-time:joda-time:2.9.9'
DateTime(value).toString(format)
} catch (e: Exception) {
""
}
}
三方库链接:
implementation 'joda-time:joda-time:2.9.9'
也是好不容易找到的可用方案,做个记录,下次备用吧