나는 로그인시 응용 프로그램에 대한 만료 날짜를 확인하도록되어 동작 버튼이 있습니다캘린더되지 검증 월에만 일 년
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
문제는 시스템 날짜는 점이다 10월 17일 2012을 분명히 로그인은 여전히 발생합니다. 그러나 2012 년에서 2011 년을 만료 날짜로 변경하면 라이센스 유효성 검사가 수행됩니다. 시스템이 2012 년 10 월 10 일의 날짜를 무시하는 문제는 무엇입니까?
(!) 참고 도움 :'expiredate.set (2012, 09, 10)를 사용하며 2012년 10월 10일을 표현하는'. 월은 0 기준입니다 ... –
당신이 옳다고 생각합니다. 나는 달이 0에서 계산된다는 것을 깨닫지 못했습니다. 감사합니다. – ErrorNotFoundException