refactored UiHelper
This commit is contained in:
parent
f02f510c18
commit
d502e57661
|
@ -51,10 +51,18 @@ public class UIHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean today(Date date) {
|
private static boolean today(Date date) {
|
||||||
|
return sameDay(date,new Date(System.currentTimeMillis()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean sameDay(long timestamp1, long timestamp2) {
|
||||||
|
return sameDay(new Date(timestamp1),new Date(timestamp2));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean sameDay(Date a, Date b) {
|
||||||
Calendar cal1 = Calendar.getInstance();
|
Calendar cal1 = Calendar.getInstance();
|
||||||
Calendar cal2 = Calendar.getInstance();
|
Calendar cal2 = Calendar.getInstance();
|
||||||
cal1.setTime(date);
|
cal1.setTime(a);
|
||||||
cal2.setTimeInMillis(System.currentTimeMillis());
|
cal2.setTime(b);
|
||||||
return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
|
return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
|
||||||
&& cal1.get(Calendar.DAY_OF_YEAR) == cal2
|
&& cal1.get(Calendar.DAY_OF_YEAR) == cal2
|
||||||
.get(Calendar.DAY_OF_YEAR);
|
.get(Calendar.DAY_OF_YEAR);
|
||||||
|
|
Loading…
Reference in New Issue