Set Date in a single line
You could use
new SimpleDateFormat( "yyyyMMdd" ).parse( "20100520" )
This is yet another reason to use Joda Time
new DateMidnight(2010, 3, 5)
DateMidnight is now deprecated but the same effect can be achieved with Joda Time DateTime
DateTime dt = new DateTime(2010, 3, 5, 0, 0);
You could use new GregorianCalendar(theYear, theMonth, theDay)
.getTime()
:
public GregorianCalendar(int year, int month, int dayOfMonth)
Constructs a GregorianCalendar with the given date set in the default time zone with the default locale.