• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to check where a date really exist in calendar?  RSS feed

 
JHM Lin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everyone!
If the GUI of an application has a JTextField representing date, and user can key in date in the JTextField. How to check the value key in by user is a valid date in calendar?
Thanks for your answering
Best Regards
 
Venkatesh Chitnis
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are writing a simple application, here are a few suggestions.
1) If you have a single text field to enter the date (assuming the format is mm/dd/yyyy), you can read the year first. You can check the condition if the is entered as desired; minimum value <= year <= maximum value.
If this condition is satisfied, you can check if the month and day entered is valid. java.util.Calendar provides with methods like getActualMinimum and getActualMaximum which you can use to check the validity of entered field.
2) A better solution is to provide a combobox from where the user can make his selection.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!