fun bind(crime: Crime){
this.crime = crime
titleTextView.text = this.crime.title
val df : DateFormat = DateFormat.getInstance().format(DateFormat.LONG, DateFormat.MEDIUM)
dateTextView.text = df.format(this.crime.date.toString())
solvedImageView.visibility = if (crime.isSolved){
View.VISIBLE
}else{
View.GONE
}
}
如何在 Kotlin 中使用日期格式库?我想将此日期格式“Sun Jul 25 00:00:00 GMT+09:00 2021”更改为“Sun, Jul, 25, 2021”。
最佳答案
您可以简单地使用以下内容:
val formattedDate = SimpleDateFormat("EE, MMM, dd, yyyy", Locale.US)
val date = formattedDate .parse(this.crime.date.toString())
关于android - 如何在 Kotlin 中使用 "android.text.format.DateFormat"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68518225/