diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2011-09-16 14:36:28 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2011-09-16 14:36:28 +0200 |
| commit | 579ef7a535489d4aa632db11667a3b01deb6cafd (patch) | |
| tree | 55810021c02ac7d80d3a9702ef0b59e4af154b9c /main/src/cgeo/geocaching/sorting/DateComparator.java | |
| parent | 96ea21fd50334479c262da692038965d0e4d596a (diff) | |
| download | cgeo-579ef7a535489d4aa632db11667a3b01deb6cafd.zip cgeo-579ef7a535489d4aa632db11667a3b01deb6cafd.tar.gz cgeo-579ef7a535489d4aa632db11667a3b01deb6cafd.tar.bz2 | |
Move sources into the main directory
This prepares the inclusion of tests into the same repository.
Diffstat (limited to 'main/src/cgeo/geocaching/sorting/DateComparator.java')
| -rw-r--r-- | main/src/cgeo/geocaching/sorting/DateComparator.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/sorting/DateComparator.java b/main/src/cgeo/geocaching/sorting/DateComparator.java new file mode 100644 index 0000000..b59e84e --- /dev/null +++ b/main/src/cgeo/geocaching/sorting/DateComparator.java @@ -0,0 +1,35 @@ +package cgeo.geocaching.sorting; + +import cgeo.geocaching.cgCache; + +import java.util.Date; + +/** + * compares caches by date + * + * @author bananeweizen + * + */ +public class DateComparator extends AbstractCacheComparator { + + @Override + protected boolean canCompare(cgCache cache1, cgCache cache2) { + return true; + } + + @Override + protected int compareCaches(cgCache cache1, cgCache cache2) { + Date date1 = cache1.hidden; + Date date2 = cache2.hidden; + if (date1 != null && date2 != null) { + return date1.compareTo(date2); + } + if (date1 != null) { + return -1; + } + if (date2 != null) { + return 1; + } + return 0; + } +} |
