From 3f4bc2836355167eff3fe7b1bca23a0fe485db57 Mon Sep 17 00:00:00 2001 From: Andrew Chen Date: Thu, 6 Sep 2012 16:35:13 -0700 Subject: [PATCH] Add null check before attempting to do math on the date. --- src/com/fsck/k9/helper/Utility.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/com/fsck/k9/helper/Utility.java b/src/com/fsck/k9/helper/Utility.java index 814692219..27ec953b0 100644 --- a/src/com/fsck/k9/helper/Utility.java +++ b/src/com/fsck/k9/helper/Utility.java @@ -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 {