Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Production problem with Calendar.setLenient(false):  RSS feed

 
aravind yarram
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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)
{
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!