我有一个操作按钮,应该在登录期间检查应用程序的过期日期:
public void actionPerformed(ActionEvent ae) {
Calendar expiredate = Calendar.getInstance();
expiredate.set(2012, 10, 10);
if (ae.getSource() == button) {
char[] temp_pwd = t_pass.getPassword();
String pwd = null;
pwd = String.copyValueOf(temp_pwd);
if (db.checkLogin(t_name.getText(), pwd)) {
try {
if (Calendar.getInstance().after(expiredate)) {
JOptionPane.showMessageDialog(null, "License has Expired\n Please Re-new the License from the Provider", "Re-new License", JOptionPane.ERROR_MESSAGE);
t_name.setText("");
t_pass.setText("");
t_name.requestFocus();
return;
}
JOptionPane.showMessageDialog(null, "You have logged in successfully. Click OK to Continue", "Success",
JOptionPane.INFORMATION_MESSAGE);
MainFrame page = new MainFrame();
page.setVisible(true);
setVisible(false);
} catch(Exception ai){
JOptionPane.showMessageDialog(null, ai, "Exception",
JOptionPane.INFORMATION_MESSAGE);
}
} else {
JOptionPane.showMessageDialog(null, "Login failed!\nWrong Username or password", "Failed!!",
JOptionPane.ERROR_MESSAGE);
t_name.setText("");
t_pass.setText("");
t_name.requestFocus();
return;
}
}//if
}//method
问题是系统日期是 2012 年 10 月 17 日。显然登录仍然发生。但是当我将 2012 更改为 2011 作为到期日期时,就会发生许可证验证。系统忽略 2012 年 10 月 10 日日期可能是什么问题?