letsbedecent
asked on
create a date for the first of month
i want to create a java.util.Date object for the first of the current month !
how ?
how ?
Calendar cal = Calendar.getInstance();
cal.set(Calendar.MONTH, 1);
Date first = cal.getTime();
cal.set(Calendar.MONTH, 1);
Date first = cal.getTime();
it should be
cal.set ( Calendar.MONTH , 0 ); for January.
Cheers,
Mukundh
cal.set ( Calendar.MONTH , 0 ); for January.
Cheers,
Mukundh
you can also set by cal.set ( Calendar.MONTH, Calendar.JANUARY )
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you !
ASKER
int month = Calendar.getInstance().get
int year = Calendar.getInstance().get
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy
Date startDate = sdf.parse(month + "/01/" + year);
is there a better way of doing this ?