"standard" Java DateBuilder implementation?

I would like to know if there is a "standard" Java DateBuilder implementation before I build it myself. I have looked at the Java and Apache Commons APIs and cannot find a link to one.

I'm looking for something simple to implement an interface like:

Date date = new DateBuilder().month(2).year(1).build();

      

where date

will be July 12, 2010 (it is assumed that today is May 12).

Also, don't go to Joda Time.

+1


a source to share


3 answers


No, but you can do the same thing (just not on the same line / chain of method calls) with the Calendar object:

//assuming your use case is "add 1 year and 2 months to the current date/time"
Calendar cal = Calendar.getInstance()
cal.clear();
cal.add(Calendar.MONTH, 2);
cal.add(Calendar.YEAR, 1);

      



In a Builder template, it should be trivial to wrap Calendar.add()

and Calendar.set()

.

+3


a source


Google codeearch opens this



Any use?

0


a source


You can wait for JSR-310 . This will be the standard in the future when it is implemented!

0


a source







All Articles