2021-05-13 19:09:10 +00:00
|
|
|
package utils;
|
2021-05-13 17:45:54 +00:00
|
|
|
|
|
|
|
import java.io.Serializable;
|
2021-05-15 14:47:52 +00:00
|
|
|
import java.text.SimpleDateFormat;
|
2021-05-13 17:45:54 +00:00
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.time.format.FormatStyle;
|
2021-05-15 14:47:52 +00:00
|
|
|
import java.util.Date;
|
2021-05-13 17:45:54 +00:00
|
|
|
|
2021-05-13 19:09:10 +00:00
|
|
|
public class Message implements Serializable {
|
|
|
|
|
2021-05-13 17:45:54 +00:00
|
|
|
String username;
|
|
|
|
String message;
|
2021-05-15 14:47:52 +00:00
|
|
|
String time = "00:00";
|
|
|
|
/*
|
|
|
|
LocalDateTime current = LocalDateTime.now();
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM);
|
|
|
|
String date = current.format(formatter);
|
|
|
|
*/
|
2021-05-13 19:09:10 +00:00
|
|
|
public Message(String username, String message) {
|
2021-05-13 17:45:54 +00:00
|
|
|
this.username = username;
|
|
|
|
this.message = message;
|
2021-05-15 14:47:52 +00:00
|
|
|
this.time = new SimpleDateFormat("HH.mm.ss").format(new Date());
|
2021-05-13 17:45:54 +00:00
|
|
|
//this.date = date;
|
|
|
|
}
|
2021-05-15 14:47:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
public String getMessage(){
|
|
|
|
return this.message;
|
|
|
|
}*/
|
2021-05-13 17:45:54 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
2021-05-13 19:09:10 +00:00
|
|
|
return "nickname=" + username
|
2021-05-15 14:47:52 +00:00
|
|
|
+ ", message=" + message
|
|
|
|
+ ", time =" + time;
|
2021-05-14 15:44:48 +00:00
|
|
|
//+ ", time=" + date;
|
2021-05-13 17:45:54 +00:00
|
|
|
}
|
2021-05-15 14:47:52 +00:00
|
|
|
|
|
|
|
public boolean exit() {
|
2021-05-15 08:45:47 +00:00
|
|
|
if(message.equalsIgnoreCase("exit")){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getMessage() {
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getUsername() {
|
|
|
|
return username;
|
|
|
|
}
|
2021-05-15 14:47:52 +00:00
|
|
|
|
|
|
|
public String getTime(){
|
|
|
|
return time;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-05-13 19:09:10 +00:00
|
|
|
|
2021-05-15 14:47:52 +00:00
|
|
|
}
|