# Formatting

You can customize how certain pieces of information are formatted by the SDK.

## Formatting Dates

Overriding the `DateFormatter` allows you to change the way dates are formatted in the application:

<tabs>

<tabs-item value="kotlin" label="Kotlin">

```kotlin
ChatUI.dateFormatter = object: DateFormatter {
    private val dateFormat: DateFormat = SimpleDateFormat("dd/MM/yyyy")
    private val timeFormat: DateFormat = SimpleDateFormat("HH:mm")

    override fun formatDate(date: Date?): String {
        date ?: return ""
        return dateFormat.format(date)
    }

    override fun formatTime(date: Date?): String {
        date ?: return ""
        return timeFormat.format(date)
    }

    override fun formatRelativeTime(date: Date?): String {
        date ?: return ""
        // Return relative time like "Just now", "5 minutes ago"
    }

    override fun formatRelativeDate(date: Date): String {
        // Return relative date like "Yesterday", "A day ago"
    }
}
```

</tabs-item>

<tabs-item value="java" label="Java">

```java
ChatUI.setDateFormatter(new DateFormatter() {
    private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    private final DateFormat timeFormat = new SimpleDateFormat("HH:mm");

    public String formatDate(Date date) {
        // Provide a way to format the date
        return dateFormat.format(date);
    }

    public String formatTime(Date date) {
        // Provide a way to format the time
        return timeFormat.format(date);
    }

    public String formatRelativeTime(Date date) {
        // Return relative time like "Just now", "5 minutes ago"
    }

    public String formatRelativeDate(Date date) {
        // Return relative date like "Yesterday", "A day ago"
    }
});

```

</tabs-item>

</tabs>

## Formatting Durations

Overriding the `DurationFormatter` allows you to change the way durations are formatted in the application:

<tabs>

<tabs-item value="kotlin" label="Kotlin">

```kotlin
ChatUI.durationFormatter = object: DurationFormatter {
    override fun format(durationInMillis: Int): String {
        // Your custom duration formatting logic
    }
}
```

</tabs-item>

<tabs-item value="java" label="Java">

```java
ChatUI.setDurationFormatter(new DurationFormatter() {
    public String format(int durationInMillis) {
        // Your custom duration formatting logic
    }
});

```

</tabs-item>

</tabs>

## Formatting Channel Names

You can customize the way channel names are formatted by overriding the default `ChannelNameFormatter`:

<tabs>

<tabs-item value="kotlin" label="Kotlin">

```kotlin
ChatUI.channelNameFormatter = ChannelNameFormatter { channel, currentUser ->
    channel.name
}
```

</tabs-item>

<tabs-item value="java" label="Java">

```java
ChatUI.setChannelNameFormatter((channel, currentUser) -> channel.getName());
```

</tabs-item>

</tabs>

## Formatting Message Previews

You can customize how message previews are formatted in channel lists by overriding the default `MessagePreviewFormatter`:

<tabs>

<tabs-item value="kotlin" label="Kotlin">

```kotlin
ChatUI.messagePreviewFormatter = MessagePreviewFormatter { channel, message, currentUser ->
    // Return custom preview text for the message
    message.text
}
```

</tabs-item>

<tabs-item value="java" label="Java">

```java
ChatUI.setMessagePreviewFormatter((channel, message, currentUser) -> {
    // Return custom preview text for the message
    return message.getText();
});
```

</tabs-item>

</tabs>

## Markdown

The SDK provides a standalone Markdown module `stream-chat-android-markdown-transformer` that contains `MarkdownTextTransformer` which is an implementation of `ChatMessageTextTransformer`. It uses the [Markwon](https://github.com/noties/Markwon) library internally.

<tabs>

<tabs-item value="kotlin" label="Kotlin">

```kotlin
ChatUI.messageTextTransformer = MarkdownTextTransformer(context)
```

</tabs-item>

<tabs-item value="java" label="Java">

```java
ChatUI.setMessageTextTransformer(new MarkdownTextTransformer(context));
```

</tabs-item>

</tabs>

If you use `MarkdownTextTransformer`, don't use `android:autoLink` attribute because it'll break the markdown [Linkify](https://noties.io/Markwon/docs/v4/linkify/) implementation.

Then the SDK will parse Markdown automatically:

| Markdown Input in the Message Composer                                                       | Message with Markdown in the Message List                                                         |
| -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| ![Markdown Input in the Message Composer](@chat-sdk/android/v6/_assets/markdown_support.png) | ![Markdown Message in the Message List](@chat-sdk/android/v6/_assets/markdown_support_result.png) |


---

This page was last updated at 2026-04-17T17:33:30.497Z.

For the most recent version of this documentation, visit [https://getstream.io/chat/docs/sdk/android/v6/ui/formatting/](https://getstream.io/chat/docs/sdk/android/v6/ui/formatting/).