Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { public static long getEndOfCurrentWeek() { Calendar calendar = getCalendarWithTime(getStartOfCurrentWeek()); calendar.add(Calendar.DATE, 6); return calendar.getTimeInMillis(); } public static Calendar getCalendarWithTime(long time) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time); return calendar; } public static long getStartOfCurrentWeek() { return getStartOfWeek(System.currentTimeMillis()); } public static long getStartOfWeek(long week) { Calendar calendar = getCalendarWithTime(week); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.clear(Calendar.MINUTE); calendar.clear(Calendar.SECOND); calendar.clear(Calendar.MILLISECOND); // get start of this week in milliseconds calendar.set(Calendar.DAY_OF_WEEK, calendar.getFirstDayOfWeek()); return calendar.getTimeInMillis(); } }