What is the accepted way to replace java.util.Date(year,month,day)
        Posted  
        
            by dagw
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by dagw
        
        
        
        Published on 2010-04-21T22:46:46Z
        Indexed on 
            2010/04/21
            22:53 UTC
        
        
        Read the original article
        Hit count: 222
        
I'm trying to do something really simple, but starting to realize that dates in Java are a bit of minefield. All I want is to get passed groups of three ints ( a year, a month and a date) create some Date objects, do some simple test on them (along the lines of as date A before date B and after January 1 1990), convert them to java.sql.Date objects and pass them off to the database via JDBC.
All very simple and works fine using the java.util.Date(int year,int month,int day) constructor. Of course that constructor is depreciated, and I'd like to avoid using depreciated calls in new code I'm writing. However all the other options to solve this simple problem seem stupidly complicated. Is there really no simple way to do what I want without using depreciated constructors?
I know the standard answer to all Java date related questions is "use joda time", but I really don't want to start pulling in third party libraries for such a seemingly trivial problem.
© Stack Overflow or respective owner