List of usage examples for java.util Calendar FRIDAY
int FRIDAY
To view the source code for java.util Calendar FRIDAY.
Click Source Link
From source file:Main.java
public static void main(String[] args) { Calendar now = Calendar.getInstance(); System.out.println(now.getTime()); int dayOfWeek = now.get(Calendar.DAY_OF_WEEK); if (Calendar.SUNDAY == dayOfWeek) { System.out.println("SUNDAY"); }//from www . j a v a 2 s . c o m if (Calendar.MONDAY == dayOfWeek) { System.out.println("MONDAY"); } if (Calendar.TUESDAY == dayOfWeek) { System.out.println("TUESDAY"); } if (Calendar.WEDNESDAY == dayOfWeek) { System.out.println("WEDNESDAY"); } if (Calendar.THURSDAY == dayOfWeek) { System.out.println("THURSDAY"); } if (Calendar.FRIDAY == dayOfWeek) { System.out.println("FRIDAY"); } if (Calendar.SATURDAY == dayOfWeek) { System.out.println("SATURDAY"); } }
From source file:MainClass.java
public static void main(String args[]) { Calendar cal = Calendar.getInstance(); Date now = new Date(); cal.setTime(now);/*from ww w .ja v a2 s. c o m*/ int dayofweek = cal.get(Calendar.DAY_OF_WEEK); if (dayofweek == Calendar.SUNDAY) System.out.println("SUNDAY"); if (dayofweek == Calendar.MONDAY) System.out.println("MONDAY"); if (dayofweek == Calendar.TUESDAY) System.out.println("TUESDAY"); if (dayofweek == Calendar.WEDNESDAY) System.out.println("WEDNESDAY"); if (dayofweek == Calendar.THURSDAY) System.out.println("THURSDAY"); if (dayofweek == Calendar.FRIDAY) System.out.println("FRIDAY"); if (dayofweek == Calendar.SATURDAY) { System.out.println("SATURDAY"); } }
From source file:Main.java
public static boolean isFridayOrSaturday() { Calendar date = new GregorianCalendar(); return date.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY || date.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY; }
From source file:Main.java
public static Date friday() { return weekDay(Calendar.FRIDAY); }
From source file:Main.java
public static Calendar getLastFriday(Calendar cal, int offset) { int dayofweek; cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) + offset); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); dayofweek = cal.get(Calendar.DAY_OF_WEEK); if (dayofweek < Calendar.FRIDAY) cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) - 7 + Calendar.FRIDAY - dayofweek); else/* ww w .j a v a 2 s . co m*/ cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) + Calendar.FRIDAY - dayofweek); return cal; }
From source file:Main.java
/** * //from w ww .j a va2 s . co m * @return */ public static String ID_DayName() { Calendar cal = Calendar.getInstance(); int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); String weekDayName = ""; if (Calendar.MONDAY == dayOfWeek) { weekDayName = "Senin"; } else if (Calendar.TUESDAY == dayOfWeek) { weekDayName = "Selasa"; } else if (Calendar.WEDNESDAY == dayOfWeek) { weekDayName = "Rabu"; } else if (Calendar.THURSDAY == dayOfWeek) { weekDayName = "Kamis"; } else if (Calendar.FRIDAY == dayOfWeek) { weekDayName = "Jumat"; } else if (Calendar.SATURDAY == dayOfWeek) { weekDayName = "Sabtu"; } else if (Calendar.SUNDAY == dayOfWeek) { weekDayName = "Minggu"; } return weekDayName; }
From source file:Main.java
public static int getDayOfWeek(Date date, int defSunday) { Calendar c = Calendar.getInstance(); c.setTime(date);/*from www . ja v a 2 s .co m*/ int day = c.get(Calendar.DAY_OF_WEEK); switch (day) { case Calendar.MONDAY: return 1; case Calendar.TUESDAY: return 2; case Calendar.WEDNESDAY: return 3; case Calendar.THURSDAY: return 4; case Calendar.FRIDAY: return 5; case Calendar.SATURDAY: return 6; case Calendar.SUNDAY: return defSunday; default: return 0; } }
From source file:Main.java
private static Date getNextBus(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/* ww w . j av a2 s. c om*/ if (cal.get(Calendar.DAY_OF_WEEK) >= Calendar.MONDAY && cal.get(Calendar.DAY_OF_WEEK) <= Calendar.THURSDAY) { if (isBefore(cal, mon_thu[mon_thu.length - 1])) { setTime(cal, findNext(cal, mon_thu)); } else if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.THURSDAY) { setTime(cal, fri[0]); cal.add(Calendar.DAY_OF_YEAR, 1); } else { setTime(cal, mon_thu[0]); cal.add(Calendar.DAY_OF_YEAR, 1); } } else if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY) { if (isBefore(cal, fri[fri.length - 1])) { setTime(cal, findNext(cal, fri)); } else { setTime(cal, mon_thu[0]); cal.add(Calendar.DAY_OF_YEAR, 3); } } else { setTime(cal, mon_thu[0]); cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); } return cal.getTime(); }
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 w ww . j a v a 2 s . 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: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 w w w . ja v a2s.co m*/ } else { if (dayCode.equals(InventoryBoxDayCode.WEEKEND)) count++; } } else { count++; } start.add(Calendar.DAY_OF_MONTH, 1); } return count; }