List of usage examples for java.util Calendar SUNDAY
int SUNDAY
To view the source code for java.util Calendar SUNDAY.
Click Source Link
From source file:Main.java
public static int getTodayPlus() { Calendar cd = Calendar.getInstance(); int ret = cd.get(Calendar.DAY_OF_WEEK); if (ret == Calendar.SUNDAY) return 6; ///* w w w. j a v a2 s . co m*/ return cd.get(Calendar.DAY_OF_WEEK) - 2;// - 1 }
From source file:Main.java
public static Date sunday() { return weekDay(Calendar.SUNDAY); }
From source file:Main.java
public static boolean isWeekend() { Calendar now = Calendar.getInstance(); return (now.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) || (now.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY); }
From source file:Main.java
public static String getLastDayOfWeek(String format) { return getDayOfWeek(format, Calendar.SUNDAY); }
From source file:Util.java
public static Date getSunday(Date today) { Calendar cal = Calendar.getInstance(); cal.setTime(today);/* www . j a v a2s .c om*/ int dow = cal.get(Calendar.DAY_OF_WEEK); while (dow != Calendar.SUNDAY) { int date = cal.get(Calendar.DATE); int month = cal.get(Calendar.MONTH); int year = cal.get(Calendar.YEAR); if (date == getMonthLastDate(month, year)) { if (month == Calendar.DECEMBER) { month = Calendar.JANUARY; cal.set(Calendar.YEAR, year + 1); } else { month++; } cal.set(Calendar.MONTH, month); date = 1; } else { date++; } cal.set(Calendar.DATE, date); dow = cal.get(Calendar.DAY_OF_WEEK); } return cal.getTime(); }
From source file:Main.java
private static void prepareCalendarStartsMonday(Calendar calendar) { if (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); if (dayOfWeek == Calendar.SUNDAY) { calendar.add(Calendar.DATE, -6); } else {/*from w w w . jav a 2 s . c o m*/ calendar.add(Calendar.DATE, -dayOfWeek + 2); } } }
From source file:Main.java
public static boolean IsItTheWeekend() { Calendar calendarToday = Calendar.getInstance(); if (calendarToday.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calendarToday.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { //TODO: //Change back to true, set to false to test information on the weekend return true; } else {/*from www .j a v a2 s. com*/ return false; } }
From source file:Main.java
/** * Get first day of week as android.text.format.Time constant. * * @return the first day of week in android.text.format.Time *///w ww .j a v a 2s. c om public static int getFirstDayOfWeek(Context context) { int startDay = Calendar.SUNDAY; if (startDay == Calendar.SATURDAY) { return Time.SATURDAY; } else if (startDay == Calendar.MONDAY) { return Time.MONDAY; } else { return Time.SUNDAY; } }
From source file:Main.java
public static String[] getWeekDays() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); String[] weekDays = new String[7]; for (int i = 0; i < 7; i++) { weekDays[i] = WEEK_DAYS_FORMAT.format(calendar.getTime()); calendar.add(Calendar.DATE, 1); }//from w ww . jav a 2 s . com return weekDays; }
From source file:Main.java
public static ArrayList<String> getCurrentWeek() { SimpleDateFormat format = new SimpleDateFormat("dd"); Calendar calendar = Calendar.getInstance(); calendar.setFirstDayOfWeek(Calendar.SUNDAY); calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); ArrayList<String> days = new ArrayList<String>(); for (int i = 0; i < 7; i++) { days.add(format.format(calendar.getTime())); calendar.add(Calendar.DAY_OF_MONTH, 1); }//ww w . ja v a 2s. c o m return days; }