-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTweet.java
More file actions
62 lines (53 loc) · 1.43 KB
/
Tweet.java
File metadata and controls
62 lines (53 loc) · 1.43 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* a class that represents a tweet
*a tweet has a date, a text, and a tweet ID
*/
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Tweet {
//////////////////fields//////////////////////////////////
/** the date of the tweet */
public Date date;
/** the text of the tweet */
public String text;
/** the tweet ID */
public String ID;
////////////////Constructors///////////////////////////
/**
*A constructor that creates a new tweet
*@param date, the date of the tweet
*@param text, the text of the tweet
*@param ID, the tweet ID
*/
public Tweet(String date, String text, String ID)
{
//Convert date to date data_type
SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss +0000 yyyy");
try {
Date dates = formatter.parse(date);
this.date=dates;
}
catch (ParseException e) {
e.printStackTrace();
}
this.text=text;
this.ID=ID;
}
///////////////////Methods///////////////////////////////
//A to String Method
public String toString()
{
return("This tweet occurred on " + this.date + "\n" + "The tweet text is: " + this.text + " " +this.ID);
}
//Get methods
public Date getDate(){
return this.date;
}
public String getText() {
return this.text;
}
public String getID() {
return this.ID;
}
}