how to get the current workweek number?

N

nkammah

I am trying to get the current workweek number, but I cannot manage to
code it easily in java ( without using external module...jsut a simple
function).

In python, I am using this line :

# (Julian Day[0..364] - Day Of Week[Mon=0,Tues=1] + 12[offset cuz Jan
1st fell on Sunday] / daysInTheWeek
workWeek = (t[7] - t[6] + 12 - (365 * (t[0] - 2006))) / 7



Any idea in java???


Regards,
 
J

John O'Conner

I am trying to get the current workweek number, but I cannot manage to
code it easily in java ( without using external module...jsut a simple
function).


How about creating a Calendar and calling get(Calendar.WEEK_OF_YEAR)?

Regards,
John O'Conner
 
N

nkammah

well, i'm sure i'd work,but I thought there would be easier way.

i'll try with the calendar . thx !
 
N

nkammah

I tried :

Calendar calADD = java.util.GregorianCalendar.getInstance();
System.out.println(calADD.WEEK_OF_YEAR);

but i get ww3, whereas i should get ww15.

In my case, january 1 2006 was in ww01. A new ww starts on monday.

Any idea of the strange result i get?
 
F

Frank Langelage

I tried :

Calendar calADD = java.util.GregorianCalendar.getInstance();
System.out.println(calADD.WEEK_OF_YEAR);

but i get ww3, whereas i should get ww15.

In my case, january 1 2006 was in ww01. A new ww starts on monday.

Any idea of the strange result i get?

You're printing the value for the public class member variable WEEK_OF_YEAR.
You should use
System.out.println( calADD.get( Calendar.WEEK_OF_YEAR ) );
..
 

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
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top