• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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)
{
}
 
It runs on an internal combustion engine. This ad does not:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic