forked from gihanjayatilaka/Motify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotificationUpdate.java
More file actions
74 lines (65 loc) · 2.2 KB
/
NotificationUpdate.java
File metadata and controls
74 lines (65 loc) · 2.2 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
63
64
65
66
67
68
69
70
71
72
73
74
import java.io.Serializable;
public class NotificationUpdate implements Comparable<NotificationUpdate>,Serializable{
int[] pubTime;
String title;
String link;
String description;
NotificationUpdate(String pubTimeText,String title,String link,String description){
this.pubTime=getPubTime(pubTimeText);
this.title=title;
this.link=link;
this.description=description.replaceAll("<p>", "").replaceAll("</p>", "").replaceAll(" ", "");
}
public int[] getPubTime(String timeString){
int[] time=new int[6];
time[0]=Integer.parseInt(timeString.substring(12,16));
time[1]=getMonthNumber(timeString.substring(8,11));
time[2]=Integer.parseInt(timeString.substring(5,7));
time[3]=Integer.parseInt(timeString.substring(17,19));
time[4]=Integer.parseInt(timeString.substring(20,22));
time[5]=Integer.parseInt(timeString.substring(23,25));
return time;
}
public int getMonthNumber(String monthText){
int n=0;
if(monthText.equals("Jan")) n=1;
if(monthText.equals("Feb")) n=2;
if(monthText.equals("Mar")) n=3;
if(monthText.equals("Apr")) n=4;
if(monthText.equals("May")) n=5;
if(monthText.equals("Jun")) n=6;
if(monthText.equals("Jul")) n=7;
if(monthText.equals("Aug")) n=8;
if(monthText.equals("Sep")) n=9;
if(monthText.equals("Oct")) n=10;
if(monthText.equals("Nov")) n=11;
if(monthText.equals("Dec")) n=12;
return n;
}
public int compareTo(NotificationUpdate notification) {
int ans=0;
if(this.pubTime[0]>notification.pubTime[0]) ans=1;
else if(this.pubTime[0]<notification.pubTime[0]) ans=-1;
else{
if(this.pubTime[1]>notification.pubTime[1]) ans=1;
else if(this.pubTime[1]<notification.pubTime[1]) ans=-1;
else{
if(this.pubTime[2]>notification.pubTime[2]) ans=1;
else if(this.pubTime[2]<notification.pubTime[2]) ans=-1;
else{
if(this.pubTime[3]>notification.pubTime[3]) ans=1;
else if(this.pubTime[3]<notification.pubTime[3]) ans=-1;
else{
if(this.pubTime[4]>notification.pubTime[4]) ans=1;
else if(this.pubTime[4]<notification.pubTime[4]) ans=-1;
else{
if(this.pubTime[4]>notification.pubTime[4]) ans=1;
else if(this.pubTime[4]<notification.pubTime[4]) ans=-1;
}
}
}
}
}
return ans;
}
}