-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMessage.java
More file actions
28 lines (23 loc) · 828 Bytes
/
Message.java
File metadata and controls
28 lines (23 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class Message {
private String nom;
private String ldt;
private String taille;
private String message;
private static DateTimeFormatter dtFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
public Message(String nom, String message) {
LocalDateTime localDT = LocalDateTime.now();
this.nom = nom;
this.ldt = localDT.format(dtFormat);
this.taille = String.valueOf(message.length());
this.message = message;
}
public String send() {
return (this.nom + "\n" + this.ldt + "\n" + this.taille + "\n" + this.message);
}
@Override
public String toString() {
return this.nom + ";" + this.ldt + ";" + this.taille + ";" + this.message;
}
}