Java examples for java.util:Week
get date of This Week
//package com.java2s; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static Date[] getThisWeek() { GregorianCalendar calendar = new GregorianCalendar(); calendar.set(GregorianCalendar.HOUR_OF_DAY, 0); calendar.set(GregorianCalendar.MINUTE, 0); calendar.set(GregorianCalendar.SECOND, 0); int minus = calendar.get(GregorianCalendar.DAY_OF_WEEK); calendar.add(GregorianCalendar.DAY_OF_WEEK, -minus + 1); calendar.set(GregorianCalendar.HOUR_OF_DAY, 0); calendar.set(GregorianCalendar.MINUTE, 0); calendar.set(GregorianCalendar.SECOND, 0); Date begin = calendar.getTime(); calendar.add(GregorianCalendar.DAY_OF_WEEK, 6); calendar.set(GregorianCalendar.HOUR_OF_DAY, 23); calendar.set(GregorianCalendar.MINUTE, 59); calendar.set(GregorianCalendar.SECOND, 59); Date end = calendar.getTime(); return new Date[] { begin, end }; }//from w w w.j a v a2 s . c om }