How to compare two unix time and check if A unix time is past B unix time? ( if A is in past)
I convert it to Date, but I just need to check if A is in past?
private String millisToDate(String s, long l){
long unixSeconds = 0;
if(!TextUtils.isEmpty(s))
unixSeconds = Long.valueOf(s);
else if(!TextUtils.isEmpty(String.valueOf(l)))
unixSeconds = l;
Date date = new Date(unixSeconds*1000L);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
return sdf.format(date);
}
I need to check if a unix time is past today date.
I did this: \
private boolean isExpiredDate(String unix) {
//SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
//String today = sdf.format(new Date());
Date today = new Date();
Date check = new Date(Long.valueOf(unix)*1000L);
Log.e(TAG, "today: " + today + "|> check: " + check);
if(check.after(today) || check.equals(today))
return true;
else
return false;
}