Topic: 日期型判断

  Print this page

1.日期型判断 Copy to clipboard
Posted by: xljba
Posted on: 2004-08-09 14:40

请问各位大虾如何判断JTextField中输入的数据是否是日期型的?

2.Re:日期型判断 [Re: xljba] Copy to clipboard
Posted by: elysium922
Posted on: 2004-08-09 17:15

假设你要在用户按下回车键时进行判断
field.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
try {
DateFormat df = DateFormat.getDefaultInstance(DateFormat.LONG, Locale.CHINA);
Date date = df.parse(field.getText());
} catch (ParseException e) {
field.setText("");
field.getToolkit.beep();
}
}
}

3.Re:日期型判断 [Re: xljba] Copy to clipboard
Posted by: xljba
Posted on: 2004-08-10 08:12

谢谢!

4.Re:日期型判断 [Re: xljba] Copy to clipboard
Posted by: 咸鱼
Posted on: 2004-08-11 08:52

不错的方法!


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923