Skip to content

Commit b7f40fe

Browse files
committed
Format date in CallLogAdapter
1 parent b674fcd commit b7f40fe

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/src/main/java/com/addev/listaspam/calllog/CallLogAdapter.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ import androidx.core.content.ContextCompat
1212
import androidx.recyclerview.widget.RecyclerView
1313
import com.addev.listaspam.R
1414
import com.addev.listaspam.utils.SpamUtils
15+
import java.text.SimpleDateFormat
16+
import java.time.format.DateTimeFormatter
1517

1618
class CallLogAdapter(
1719
private val context: Context,
1820
private val callLogs: List<CallLogEntry>,
1921
private val blockedNumbers: Set<String>
2022
) : RecyclerView.Adapter<CallLogAdapter.CallLogViewHolder>() {
2123

24+
val formatter = SimpleDateFormat("dd/MM/yyyy")
25+
2226
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CallLogViewHolder {
2327
val view = LayoutInflater.from(context).inflate(R.layout.item_call_log, parent, false)
2428
return CallLogViewHolder(view)
@@ -39,7 +43,7 @@ class CallLogAdapter(
3943

4044
fun bind(callLog: CallLogEntry, isBlocked: Boolean) {
4145
numberTextView.text = "${callLog.number}${if (isBlocked) " (blocked)" else ""}"
42-
dateTextView.text = callLog.date.toString()
46+
dateTextView.text = formatter.format(callLog.date)
4347
durationTextView.text = "Duration: ${callLog.duration} seconds"
4448

4549
if (isBlocked) {

0 commit comments

Comments
 (0)