-5

我正在编写一个程序,在该程序中我必须弄清楚当月有人第一次登录我的 JavaFX 应用程序。我一直试图找出答案,但没有结果。请帮忙谢谢!

编辑1:

这是图像 在图像中有一个未结余额存储在 MySQL 服务器中,我想在每个月的第一次登录时通过电子邮件发送该金额。

4

1 回答 1

0

好吧,您需要在某处为每个用户保存该日期,并在每次用户成功登录应用程序时确定它。

一个简单的通用方法可能是这样的:

/* Called after successfull login */
public void loginWasSuccessfullForUser(User user)
{
    Date first_login_in_month;

    /* Get the saved date. */
    first_login_in_month = getFirstMonthlyLoginForUser(user);

    /* Is it in the current month? */
    if (first_login_in_month != null
        && dateIsInCurrentMonth(first_login_in_month))
    {
      /* Logging in again this month... nothing to do. */
      return;
    }

    /* No date saved yet (first login) or first login this month. */
    first_login_in_month = getCurrentTimeFromSomewhere();
    saveFirstMonthlyLoginForUser(first_login_in_month, user);
}
于 2017-06-29T12:19:02.797 回答