package com.insa.app.model;
import java.sql.Timestamp;
import java.util.Calendar;

public class Message {

    private String content;

    public Message(String emitter, String content) {
        Calendar calendar = Calendar.getInstance();
        Timestamp timestamp = new Timestamp(System.currentTimeMillis());

        calendar.setTimeInMillis(timestamp.getTime());
        int hour = calendar.get(Calendar.HOUR);
        int minute = calendar.get(Calendar.MINUTE);
        int second = calendar.get(Calendar.SECOND);
        this.content = String.format("%dh%2d:%2d - %s : %s", hour, minute, second, emitter, content);
    }

    public Message(String emitter, String content, String timestamp) {
        this.content = String.format("%s - %s : %s",timestamp, emitter, content);
    }

    @Override
    public String toString() {
        return content;
    }
}
