Skip to main content
Version: v4

Date

CometChatDate is a widget which is used to show the date and time. You can also customize the appearance of this widget by modifying its logic.

How to integrate CometChatDate ?

Since CometChatDate is a widget, it can be added directly in the build method. CometChatDate includes various parameters to customize its UI.

Usage

<com.cometchat.chatuikit.shared.views.CometChatDate.CometChatDate
android:id="@+id/txt_message_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>

Methods

MethodsTypeDescription
setDatelong,StringThis method accept two parameters, time stamp in sec and date format in which you want to display time
setPatternPatternUsed to set pattern with different logics TIME,DAY_DATE,DAY_DATE_TIME
setCustomDateStringStringtext to show instead of date from DateTime object
setStyleDateStyleused to customize the appearance of this widget

DateStyle

MethodsTypeDescription
setTextAppearanceTextStyleUsed to set text style of date component
setBackgroundColorUsed to set the background color
setBorderWidthBoxBorderused to set border
setCornerRadiusdoubleused to set the corner radius
setBackgroundDrawableused to set a Drawable background

Usage

CometChatDate date=view.findViewById(R.id.date);
date.setStyle(new DateStyle().setTextAppearance(R.style.TextAppearance_AppCompat));