Convert week number to date

G

Grzegorz Stasica

Hi'

I'm looking for a function which will return Date object base on week
number:
Something like this,
public Date SomeClass(int week,int year){
return first day of selected week
}
 
T

Thomas Weidenfeller

Grzegorz Stasica said:
I'm looking for a function which will return Date object base on week
number:
Something like this,
public Date SomeClass(int week,int year){
return first day of selected week
}

java.util.Calendar, WEEK_OF_YEAR.

/Thomas
 
V

VisionSet

Grzegorz Stasica said:
I'm looking for a function which will return Date object base on week
number:
Something like this,
public Date SomeClass(int week,int year){
return first day of selected week
}

GregorianCalendar cal = new GregorianCalendar();
cal.set(Calendar.YEAR, 2003);
cal.set(Calendar.WEEK_OF_YEAR, 45);

cal.set(Calendar.DAY_OF_WEEK, 1);

Date myDate = cal.getTime();
 
S

Sudsy

Grzegorz said:
Hi'

I'm looking for a function which will return Date object base on week
number:
Something like this,
public Date SomeClass(int week,int year){
return first day of selected week
}

Something like this?

public static Date getDate( int week, int year ) {
GregorianCalendar cal = new GregorianCalendar();
cal.set( Calendar.YEAR, year );
cal.set( Calendar.HOUR, 12 );
cal.set( Calendar.MINUTE, 0 );
cal.set( Calendar.SECOND, 0 );
cal.set( Calendar.WEEK_OF_YEAR, week );
cal.set( Calendar.DAY_OF_WEEK, Calendar.MONDAY );
return( cal.getTime() );
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top