package custom;
import java.util.Date;
import java.util.Locale;
import com.ibm.icu.util.Calendar;
public class GetStartFinishDateTimeOfWeekOfDay {
public static Date GetStartDateTimeOfDay(Date reportDate) {
Calendar cal = Calendar.getInstance(new Locale("ru", "UA"));
cal.setTime(reportDate);
cal.set(Calendar.MILLISECONDS_IN_DAY, 0);
reportDate = cal.getTime();
return reportDate;
}
public static Date GetFinishDateTimeOfDay(Date reportDate) {
Calendar cal = Calendar.getInstance(new Locale("ru", "UA"));
cal.setTime(reportDate);
cal.set(Calendar.MILLISECONDS_IN_DAY, 86399999);
reportDate = cal.getTime();
return reportDate;
}
public static Date GetStartDateTimeOfWeek(Date reportDate) {
Calendar cal = Calendar.getInstance(new Locale("ru", "UA"));
cal.setTime(reportDate);
cal.setFirstDayOfWeek(Calendar.MONDAY);
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
cal.set(Calendar.MILLISECONDS_IN_DAY, 0);
Date startWeekDate = cal.getTime();
return startWeekDate;
}
// last day is Sunday
public static Date GetFinishDateTimeOfWeek(Date reportDate) {
Calendar cal = Calendar.getInstance(new Locale("ru", "UA"));
cal.setTime(reportDate);
cal.setFirstDayOfWeek(Calendar.MONDAY);
cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
cal.set(Calendar.MILLISECONDS_IN_DAY, 86399999);
Date finishWeekDate = cal.getTime();
return finishWeekDate;
}
// last day is Friday
public static Date GetFinishDateTimeOfWeek_Work(Date reportDate) {
Calendar cal = Calendar.getInstance(new Locale("ru", "UA"));
cal.setTime(reportDate);
cal.setFirstDayOfWeek(Calendar.MONDAY);
cal.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
cal.set(Calendar.MILLISECONDS_IN_DAY, 86399999);
Date finishWeekDate = cal.getTime();
return finishWeekDate;
}
}