Java如何找到月份的第一次登录
问题描述:
我正在编写一个程序,在该程序中,我必须找出一个人第一次在当月登录到我的JavaFX应用程序。我一直在试图找出答案,但没有结果。 请帮助谢谢!Java如何找到月份的第一次登录
编辑1:
This is the image 在图像出现是存储在MySQL服务器中的存款余额,我想在每一个月的第一次登录到邮件量。
答
那么,你需要为每个用户保存这个日期,并在每次用户成功登录到应用程序时确定它。
一种简单通用的方法可能是这样的:
/* 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);
}
+0
嗯,这看起来不错。我想将信息存储在数据库中,但遇到了一些冲突。我想为每个用户的信息添加一个标志,并且在首次登录时,我会更改标志的值,但问题在于重置标志。 什么信息会得到FirstMonthlyLoginForUser()返回? –
请参阅:[?为什么?“有人可以帮助我”不是一个实际问题(http://meta.*.com/ q/284236) –
您可能必须存储登录会话;包括姓名和时间戳;然后搜索那些。很多东西,那么你的问题到底是什么?提示:显示代码并解释您的实际问题。 – GhostCat