List of usage examples for java.util Calendar MONDAY
int MONDAY
To view the source code for java.util Calendar MONDAY.
Click Source Link
From source file:Main.java
public static String getDateString() { String stringDate = ""; Calendar calendar = Calendar.getInstance(); int day = calendar.get(Calendar.DAY_OF_WEEK); int month = calendar.get(Calendar.MONTH); int dayInt = calendar.get(Calendar.DAY_OF_MONTH); switch (day) { case Calendar.SUNDAY: stringDate += "Sunday"; break;//from ww w .ja v a 2s. c o m case Calendar.MONDAY: stringDate += "Monday"; break; case Calendar.TUESDAY: stringDate += "Tuesday"; break; case Calendar.WEDNESDAY: stringDate += "Wednesday"; break; case Calendar.THURSDAY: stringDate += "Thursday"; break; case Calendar.FRIDAY: stringDate += "Friday"; break; case Calendar.SATURDAY: stringDate += "Saturday"; break; } switch (month) { case Calendar.JANUARY: stringDate += ", January"; break; case Calendar.FEBRUARY: stringDate += ", February"; break; case Calendar.MARCH: stringDate += ", March"; break; case Calendar.APRIL: stringDate += ", April"; break; case Calendar.MAY: stringDate += ", May"; break; case Calendar.JUNE: stringDate += ", June"; break; case Calendar.JULY: stringDate += ", July"; break; case Calendar.AUGUST: stringDate += ", August"; break; case Calendar.SEPTEMBER: stringDate += ", September"; break; case Calendar.OCTOBER: stringDate += ", October"; break; case Calendar.NOVEMBER: stringDate += ", November"; break; case Calendar.DECEMBER: stringDate += ", December"; break; } stringDate += (" " + dayInt); return stringDate; }
From source file:Main.java
public static long getPeriodStart(int periodType, long date) { final Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(date);//w w w . ja va2 s . c o m switch (periodType) { case TYPE_DAY: { cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); break; } case TYPE_WEEK: { cal.setFirstDayOfWeek(Calendar.MONDAY); final int currentDayOfWeek = (cal.get(Calendar.DAY_OF_WEEK) + 7 - cal.getFirstDayOfWeek()) % 7; cal.add(Calendar.DAY_OF_YEAR, -currentDayOfWeek); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); break; } case TYPE_MONTH: { cal.set(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); break; } case TYPE_YEAR: { cal.set(Calendar.MONTH, 0); cal.set(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); break; } } return cal.getTimeInMillis(); }
From source file:Util.java
public static Date getMonday(Date today) { Calendar cal = Calendar.getInstance(); cal.setTime(today);// ww w . j a va2 s.c om int dow = cal.get(Calendar.DAY_OF_WEEK); while (dow != Calendar.MONDAY) { int date = cal.get(Calendar.DATE); if (date == 1) { int month = cal.get(Calendar.MONTH); if (month == Calendar.JANUARY) { month = Calendar.DECEMBER; cal.set(Calendar.YEAR, cal.get(Calendar.YEAR) - 1); } else { month--; } cal.set(Calendar.MONTH, month); date = getMonthLastDate(month, cal.get(Calendar.YEAR)); } else { date--; } cal.set(Calendar.DATE, date); dow = cal.get(Calendar.DAY_OF_WEEK); } return cal.getTime(); }
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 *//*from ww w.j a v a2 s.c o m*/ public static int getFirstDayOfWeek() { int startDay = Calendar.getInstance().getFirstDayOfWeek(); if (startDay == Calendar.SATURDAY) { return Time.SATURDAY; } else if (startDay == Calendar.MONDAY) { return Time.MONDAY; } else { return Time.SUNDAY; } }
From source file:com.castis.xylophone.adsmadapter.common.util.CiDateUtil.java
public static int countDay(Calendar start, Calendar end, InventoryBoxDayCode dayCode) { int count = 0; while (start.compareTo(end) <= 0) { int day = start.get(Calendar.DAY_OF_WEEK); if (dayCode != null) { if (Calendar.MONDAY <= day && Calendar.FRIDAY >= day) { if (dayCode.equals(InventoryBoxDayCode.WEEKDAY)) count++;/*from www . ja v a 2 s. c om*/ } else { if (dayCode.equals(InventoryBoxDayCode.WEEKEND)) count++; } } else { count++; } start.add(Calendar.DAY_OF_MONTH, 1); } return count; }
From source file:Main.java
public static boolean isCheckChangePermitted(Context context, Calendar date) { SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); String limitActivePref = sharedPrefs.getString("active-date-key", "ALLOW_ALL"); Calendar today = Calendar.getInstance(); today.set(Calendar.HOUR_OF_DAY, 0); today.set(Calendar.MINUTE, 0); today.set(Calendar.SECOND, 0); today.set(Calendar.MILLISECOND, 0); Calendar yesterday;/*from w ww . j a v a 2s .co m*/ switch (limitActivePref) { case "ALLOW_CURRENT": return (date.compareTo(today) == 0); case "ALLOW_CURRENT_AND_NEXT_DAY": yesterday = (Calendar) today.clone(); yesterday.add(Calendar.DATE, -1); return (date.compareTo(yesterday) >= 0); case "ALLOW_CURRENT_AND_NEXT_DAY_AND_WEEKEND": yesterday = (Calendar) today.clone(); yesterday.add(Calendar.DATE, today.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY ? -2 : -1); return (date.compareTo(yesterday) >= 0); case "ALLOW_ALL": default: return true; } }
From source file:Main.java
/** * Converts the day of the week from android.text.format.Time to java.util.Calendar *//*from w ww . j a v a 2 s . c o m*/ public static int convertDayOfWeekFromTimeToCalendar(int timeDayOfWeek) { switch (timeDayOfWeek) { case Time.MONDAY: return Calendar.MONDAY; case Time.TUESDAY: return Calendar.TUESDAY; case Time.WEDNESDAY: return Calendar.WEDNESDAY; case Time.THURSDAY: return Calendar.THURSDAY; case Time.FRIDAY: return Calendar.FRIDAY; case Time.SATURDAY: return Calendar.SATURDAY; case Time.SUNDAY: return Calendar.SUNDAY; default: throw new IllegalArgumentException("Argument must be between Time.SUNDAY and " + "Time.SATURDAY"); } }
From source file:jp.classmethod.aws.brian.job.BrianQuartzJobBean.java
static SimpleDateFormat createFormat() { SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT); Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("Japan")); // TODO localize calendar.setMinimalDaysInFirstWeek(4); calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setTimeInMillis(0);/*www . java2s . c om*/ format.setCalendar(calendar); return format; }
From source file:com.mirth.connect.donkey.model.channel.PollConnectorPropertiesAdvanced.java
public PollConnectorPropertiesAdvanced() { weekly = true;/* w w w. ja v a 2s . co m*/ inactiveDays = new boolean[8]; inactiveDays[Calendar.SUNDAY] = false; // true means to exclude inactiveDays[Calendar.MONDAY] = false; inactiveDays[Calendar.TUESDAY] = false; inactiveDays[Calendar.WEDNESDAY] = false; inactiveDays[Calendar.THURSDAY] = false; inactiveDays[Calendar.FRIDAY] = false; inactiveDays[Calendar.SATURDAY] = false; dayOfMonth = 1; allDay = true; startingHour = 8; startingMinute = endingMinute = 0; endingHour = 17; }
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 2 s .c om public static int getFirstDayOfWeek(Context context) { int startDay = Calendar.getInstance().getFirstDayOfWeek(); if (startDay == Calendar.SATURDAY) { return Time.SATURDAY; } else if (startDay == Calendar.MONDAY) { return Time.MONDAY; } else { return Time.SUNDAY; } }