Commit 794df526 by Yannine Alvarez

Agregar formato fecha en el cardview dias en numero y mes en letras.

parent dc67dd59
package com.example.ayudapy
import android.content.Context
import android.os.Build
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.pendientes_items.view.*
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.time.format.FormatStyle
class RecyclerViewAdapter(val pedido: List<PedidoSave>)
: RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder>(){
......@@ -18,9 +24,29 @@ class RecyclerViewAdapter(val pedido: List<PedidoSave>)
return ViewHolder(v)
}
@RequiresApi(Build.VERSION_CODES.O)
override fun onBindViewHolder(holder: RecyclerViewAdapter.ViewHolder, position: Int) {
// localDate.getDayOfMonth();
//localDate.getMonthValue();
val formatter = DateTimeFormatter.BASIC_ISO_DATE
val formatted = pedido[position].added.format(formatter)
val fecha = formatted.substring(8..9)
// dateTime.format(DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM))
val parsedDate = LocalDateTime.parse(pedido[position].added, DateTimeFormatter.ISO_DATE_TIME)
val formatteDate = parsedDate.format(DateTimeFormatter.ofPattern("dd MMM yyyy HH:mm"))
val mes = formatteDate.substring(3..5)
println("Este es el substring de mes: $mes y este es formateadp $formatteDate")
holder.date_day.text = pedido[position].added
holder.date_day.text = fecha
holder.date_month.text = mes.toUpperCase()
holder.title.text = pedido[position].title
holder.message_view.text = pedido[position].message
}
......@@ -39,6 +65,7 @@ class RecyclerViewAdapter(val pedido: List<PedidoSave>)
class ViewHolder(itemView:View): RecyclerView.ViewHolder(itemView){
val date_day = itemView.date_day
val date_month = itemView.date_month
val title = itemView.title
val message_view = itemView.message_view
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment