package com.nurulwafa.nufakuproject;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class ChatModel {
    private String sender;
    private String message;
    private String timestamp;
    private Date parsedTimestamp;

    public ChatModel(String sender, String message, String timestamp) {
        this.sender = sender;
        this.message = message;
        this.timestamp = timestamp;

        // Parse timestamp ke Date saat objek dibuat
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
            this.parsedTimestamp = sdf.parse(timestamp);
        } catch (ParseException e) {
            e.printStackTrace();
            this.parsedTimestamp = new Date(); // fallback: waktu saat ini
        }
    }

    public String getSender() {
        return sender;
    }

    public String getMessage() {
        return message;
    }

    public String getTimestamp() {
        return timestamp;
    }

    public Date getParsedTimestamp() {
        return parsedTimestamp;
    }
}

