-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPost.java
More file actions
49 lines (36 loc) · 1008 Bytes
/
Copy pathPost.java
File metadata and controls
49 lines (36 loc) · 1008 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package PamakBook;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class Post implements Serializable{
private static final long serialVersionUID = -3629051814124279721L;
private LocalDateTime timestamp;
private String text;
private User user;
public Post(String text, User user) {
this.timestamp = LocalDateTime.now(); //setting as timestamp the current timestamp
this.text = text;
this.user = user;
this.user.setPost(this);
}
//getters
public String getTimestamp() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
return timestamp.format(formatter); //returns formated timestamp
}
public String getText() {
return text;
}
public String getUserName() {
return user.getName();
}
public String getUserEmail() {
return user.getEmail();
}
@Override
public String toString()
{
return timestamp+ ", " + text + ", "+ user.getName();
}
}
//Artemis Dara-2025