Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get starting date of first week in a year.

Status
Not open for further replies.

ProInfo

Programmer
Jul 20, 2011
20
US
Hello fellow forum members!!!

I am using Calendar.WEEK_OF_YEAR to return to me an integer of 1-53, my week is set to start on Monday's. So the first week of 2011, was December 27th, 2010 - January 2nd, 2011.

I need some help writing a function, or using built in functions to return to me the first day of Week 1.

String x = getFirstDay(1,2011);

String getFirstDay(int weeknumber, int year )
{
//some helpful code here! I'm lost!
returns "12-27-2011";
}

Thank you for any help!!!

Tim
 
Never mind guys! I figured it out!

Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 2011);
cal.set(Calendar.WEEK_OF_YEAR, 1);
cal.set(Calendar.DAY_OF_WEEK, 2);
cal.set(Calendar.HOUR, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
out.println(cal.getTime());

//Displays "Mon Dec 27 00:00:00 EST 2010
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top