We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
You're checking whether the context is null and then still continue to make use of it even though it is null.
public String getTimeAgo(Date startDate) { // date counting is done till todays date Date endDate = dateTimeNow; // time difference in milli seconds long different = endDate.getTime() - startDate.getTime(); if (context==null) { if (different < MINUTE_MILLIS) { return context.getResources().getString(R.string.just_now); } else if (different < 2 * MINUTE_MILLIS) { return context.getResources().getString(R.string.a_min_ago); } else if (different < 50 * MINUTE_MILLIS) { return different / MINUTE_MILLIS + context.getString(R.string.mins_ago); } else if (different < 90 * MINUTE_MILLIS) { return context.getString(R.string.a_hour_ago); } else if (different < 24 * HOUR_MILLIS) { timeFromData = timeFormat.format(startDate); return timeFromData; } else if (different < 48 * HOUR_MILLIS) { return context.getString(R.string.yesterday); } else if (different < 7 * DAY_MILLIS) { return different / DAY_MILLIS + context.getString(R.string.days_ago); } else if (different < 2 * WEEKS_MILLIS) { return different / WEEKS_MILLIS + context.getString(R.string.week_ago); } else if (different < 3.5 * WEEKS_MILLIS) { return different / WEEKS_MILLIS + context.getString(R.string.weeks_ago); } else { pastDate = dateFormat.format(startDate); return pastDate; } } else { if (different < MINUTE_MILLIS) { return context.getResources().getString(R.string.just_now); } else if (different < 2 * MINUTE_MILLIS) { return context.getResources().getString(R.string.a_min_ago); } else if (different < 50 * MINUTE_MILLIS) { return different / MINUTE_MILLIS + context.getString(R.string.mins_ago); } else if (different < 90 * MINUTE_MILLIS) { return context.getString(R.string.a_hour_ago); } else if (different < 24 * HOUR_MILLIS) { timeFromData = timeFormat.format(startDate); return timeFromData; } else if (different < 48 * HOUR_MILLIS) { return context.getString(R.string.yesterday); } else if (different < 7 * DAY_MILLIS) { return different / DAY_MILLIS + context.getString(R.string.days_ago); } else if (different < 2 * WEEKS_MILLIS) { return different / WEEKS_MILLIS + context.getString(R.string.week_ago); } else if (different < 3.5 * WEEKS_MILLIS) { return different / WEEKS_MILLIS + context.getString(R.string.weeks_ago); } else { pastDate = dateFormat.format(startDate); return pastDate; } } }
I took the liberty to report the issue but otherwise I had since switched to PrettyTime
The text was updated successfully, but these errors were encountered:
No branches or pull requests
You're checking whether the context is null and then still continue to make use of it even though it is null.
I took the liberty to report the issue but otherwise I had since switched to PrettyTime
The text was updated successfully, but these errors were encountered: