public class DateComparator extends java.lang.Object implements java.util.Comparator<NewsStory>
The DateComparator compares the dates of two news stories. If the dates are equals, it considers time of publication.
For time of publication, newspaper stories considered to be published first thing in the morning, followed by morning broadcasts for TV and morning snapshots for online news sources, followed by afternoon TV broadcasts and afternoon snapshots for online news sources, followed by evening TV broadcasts, followed by late night TV broadcasts.
Note that the constructor has nothing to do, so it is omitted.
Modifier and Type | Field and Description |
---|---|
static DateComparator |
DATE_COMPARATOR
We create a single comparator object for the class and make a public
final field that references that object.
|
Constructor and Description |
---|
DateComparator() |
Modifier and Type | Method and Description |
---|---|
int |
compare(NewsStory newsStory1,
NewsStory newsStory2)
The required
compare method for implementing
Comparator . |
public static final DateComparator DATE_COMPARATOR
public int compare(NewsStory newsStory1, NewsStory newsStory2)
compare
method for implementing
Comparator
.compare
in interface java.util.Comparator<NewsStory>
newsStory1
- The first news story to compare based on date/part of day.newsStory2
- The second news story to compare based on date/part of day.