• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to check where a date really exist in calendar?

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
When people don’t understand what you are doing they call you crazy. But this tiny ad just doesn't care:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic