Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Production problem with Calendar.setLenient(false):

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

The following is the code I am using to check the validity of the date. It was working fine till December 30. However it started trowing the "java.lang.IllegalArgumentException" starting from dec 31st, 2004. I am not sure why. But if I comment the "calendar.setLenient(false)" everything works fine. Any help would be highly appreciated.


try
{
java.util.Calendar calendar = java.util.Calendar.getInstance();
calendar.setLenient(false);
calendar.set(1966, 10, 21);
calendar.getTime();//throws if invalid
}
catch(Exception e)
{
}
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic