Here you can find the source of getFirstday_Lastday_Week()
public static List<Long> getFirstday_Lastday_Week() throws ParseException
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.List; public class Main { public static List<Long> getFirstday_Lastday_Week() throws ParseException { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar calendar = Calendar.getInstance(); int w = calendar.get(Calendar.DAY_OF_WEEK); calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) - w); String day_last = df.format(calendar.getTime()); StringBuffer str = new StringBuffer().append(day_last).append(" 23:59:59"); day_last = str.toString();/*from ww w . ja v a2s. c om*/ long dayLast = df2.parse(day_last).getTime(); Calendar c2 = Calendar.getInstance(); c2.set(Calendar.DAY_OF_MONTH, c2.get(Calendar.DAY_OF_MONTH) - w - 6); String day_first = df.format(c2.getTime()); StringBuffer str2 = new StringBuffer().append(day_first).append(" 00:00:00"); day_first = str2.toString(); long dayFirst = df2.parse(day_first).getTime(); List<Long> list = new ArrayList<Long>(); list.add(0, dayFirst); list.add(1, dayLast); return list; } }