Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

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

 
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
 
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.
 
Don't touch me. And dont' touch this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!