Get dates of current week
I want to know the dates of the current week, starting from mon to sun.
the current date is no problem and the current week isn't a problem either.
I set up a test where i get a couple of info from the current time:
Calendar cal = Calendar.getInstance();
an example of the result:
int day = cal.get(Calendar.DATE);
int week = cal.get(Calendar.WEEK_OF_YEAR);
int month = cal.get(Calendar.MONTH) + 1;
int year = cal.get(Calendar.YEAR);
int dow = cal.get(Calendar.DAY_OF_WEEK);
int dom = cal.get(Calendar.DAY_OF_MONTH);
int doy = cal.get(Calendar.DAY_OF_YEAR);
System.out.println("Current Date: " + cal.getTime());
System.out.println("Day: " + day);
System.out.println("Month: " + month);
System.out.println("Year: " + year);
System.out.println("Weeknumber: " + week);
System.out.println("Day of Week: " + dow);
System.out.println("Day of Month: " + dom);
System.out.println("Day of Year: " + doy);
Current Date: Tue Nov 18 11:10:26 CET 2008
Day of Week: 3
Day of Month: 18
Day of Year: 323
So how could i get the start and enddate of this week? (considering Mon is day 1 instead of 2 and sunday is 7 instead of 1)?
and how can i convert those dates to epochs?