package twitter;

import java.text.DateFormat;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity
public class Twitter implements Comparable<Twitter> {

	@Column
	private Date date;
	@Column
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	@Column
	private String status;

	public Twitter() {
	}

	public Twitter(String status, Date date) {
		this.setStatus(status);
		this.date = date;
	}

	@Override
	public int compareTo(Twitter t) {
		return t.getDate().compareTo(date);
	}

	public String dateShow() {
		DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.FULL);
		return dateFormat.format(date);
	}

	public Date getDate() {
		return date;
	}

	public Long getId() {
		return id;
	}

	public String getStatus() {
		return status;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Override
	public String toString() {
		return dateShow() + ":" + status;
	}
}
