mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-26 09:38:52 -05:00
Add null check before attempting to do math on the date.
This commit is contained in:
parent
513126fe08
commit
3f4bc28363
@ -211,12 +211,15 @@ public class Utility {
|
||||
|
||||
private static final long MILISECONDS_IN_18_HOURS = 18 * 60 * 60 * 1000;
|
||||
/**
|
||||
* Returns true if the specified date is within 18 hours of "now". Returns false otherwise.
|
||||
* @param date
|
||||
* @return
|
||||
* Check a date to see if it was from "today."
|
||||
* @param date Date of item to check.
|
||||
* @return true if the specified date is within 18 hours of now.
|
||||
*/
|
||||
public static boolean isDateToday(Date date) {
|
||||
Date now = new Date();
|
||||
public static boolean isDateToday(final Date date) {
|
||||
if (date == null) {
|
||||
return false;
|
||||
}
|
||||
final Date now = new Date();
|
||||
if (now.getTime() - MILISECONDS_IN_18_HOURS > date.getTime() || now.getTime() + MILISECONDS_IN_18_HOURS < date.getTime()) {
|
||||
return false;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user