Revision 51116
Added by Claudio Atzori over 6 years ago
modules/dnet-actionmanager-api/trunk/src/main/java/eu/dnetlib/actionmanager/set/ActionManagerSet.java | ||
---|---|---|
3 | 3 |
import java.io.Serializable; |
4 | 4 |
import java.text.ParseException; |
5 | 5 |
import java.util.*; |
6 |
|
|
7 | 6 |
import javax.xml.bind.annotation.XmlRootElement; |
8 | 7 |
|
9 |
import com.google.common.collect.Collections2; |
|
10 |
import com.google.common.collect.Lists; |
|
11 |
import org.apache.commons.lang.time.DateUtils; |
|
8 |
import org.apache.commons.lang3.time.DateUtils; |
|
12 | 9 |
|
13 | 10 |
@XmlRootElement |
14 | 11 |
public class ActionManagerSet implements Serializable { |
... | ... | |
104 | 101 |
} |
105 | 102 |
|
106 | 103 |
private Comparator<RawSet> getRawSetComparator() { |
107 |
return new Comparator<RawSet>() { |
|
108 |
@Override |
|
109 |
public int compare(final RawSet o1, final RawSet o2) { |
|
110 |
try { |
|
111 |
final Date d1 = DateUtils.parseDate(o1.getLastUpdate(), DATE_PATTERNS); |
|
112 |
final Date d2 = DateUtils.parseDate(o2.getLastUpdate(), DATE_PATTERNS); |
|
113 |
return d1.compareTo(d2); |
|
114 |
} catch (ParseException e) { |
|
115 |
throw new RuntimeException( |
|
116 |
String.format("unable to parse dates: %s, %s. Known patterns: %s", o1.getLastUpdate(), o2.getLastUpdate(), Arrays.asList(DATE_PATTERNS))); |
|
117 |
} |
|
104 |
return (o1, o2) -> { |
|
105 |
try { |
|
106 |
final Date d1 = DateUtils.parseDate(o1.getLastUpdate(), DATE_PATTERNS); |
|
107 |
final Date d2 = DateUtils.parseDate(o2.getLastUpdate(), DATE_PATTERNS); |
|
108 |
return d1.compareTo(d2); |
|
109 |
} catch (ParseException e) { |
|
110 |
throw new RuntimeException( |
|
111 |
String.format("unable to parse dates: %s, %s. Known patterns: %s", o1.getLastUpdate(), o2.getLastUpdate(), Arrays.asList(DATE_PATTERNS))); |
|
118 | 112 |
} |
119 | 113 |
}; |
120 | 114 |
} |
Also available in: Unified diff
using apache commons lang3