List of usage examples for java.util Calendar DAY_OF_WEEK
int DAY_OF_WEEK
To view the source code for java.util Calendar DAY_OF_WEEK.
Click Source Link
get
and set
indicating the day of the week. From source file:Main.java
public static void main(String[] args) { Calendar now = Calendar.getInstance(); Locale locale = Locale.getDefault(); String n = now.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, locale); System.out.printf(n);// www . j a v a 2 s . com }
From source file:Main.java
public static void main(String[] argv) throws Exception { Calendar xmas = new GregorianCalendar(1998, Calendar.DECEMBER, 25); int dayOfWeek = xmas.get(Calendar.DAY_OF_WEEK); // 6=Friday Calendar cal = new GregorianCalendar(2003, Calendar.JANUARY, 1); dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); // 4=Wednesday }
From source file:Main.java
public static void main(String[] args) { int dayOfWeek = Calendar.SUNDAY; Calendar cal = new GregorianCalendar(); cal.set(2015, 0, 1, 0, 0);/* ww w.j a v a 2 s . c o m*/ cal.set(Calendar.DAY_OF_WEEK, dayOfWeek); while (cal.get(Calendar.YEAR) == 2015) { System.out.println(cal.getTime()); cal.add(Calendar.DAY_OF_MONTH, 7); } }
From source file:Main.java
public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); int lastDate = calendar.getActualMaximum(Calendar.DATE); calendar.set(Calendar.DATE, lastDate); int lastDay = calendar.get(Calendar.DAY_OF_WEEK); System.out.println("Last Date: " + calendar.getTime()); System.out.println("Last Day : " + lastDay); }
From source file:Main.java
public static void main(String[] args) { String dayNames[] = new DateFormatSymbols().getWeekdays(); Calendar date2 = Calendar.getInstance(); System.out.println("Today is a " + dayNames[date2.get(Calendar.DAY_OF_WEEK)]); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); int day = cal.get(Calendar.DATE); int month = cal.get(Calendar.MONTH) + 1; int year = cal.get(Calendar.YEAR); int dow = cal.get(Calendar.DAY_OF_WEEK); int dom = cal.get(Calendar.DAY_OF_MONTH); int doy = cal.get(Calendar.DAY_OF_YEAR); System.out.println("Current Date: " + cal.getTime()); System.out.println("Day: " + day); System.out.println("Month: " + month); System.out.println("Year: " + year); System.out.println("Day of Week: " + dow); System.out.println("Day of Month: " + dom); System.out.println("Day of Year: " + doy); }
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.j a v a 2 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 void main(String[] args) { Calendar now = Calendar.getInstance(); String[] strDays = new String[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thusday", "Friday", "Saturday" }; System.out.println("Current day is : " + strDays[now.get(Calendar.DAY_OF_WEEK) - 1]); }
From source file:DisplayNames.java
public static void main(String args[]) { Calendar now = Calendar.getInstance(); // Locale locale = Locale.getDefault(); Locale locale = Locale.ITALIAN; Map<String, Integer> names = now.getDisplayNames(Calendar.DAY_OF_WEEK, Calendar.LONG, locale); System.out.println(names);//w ww. j a v a2 s . c o m String name = now.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, locale); System.out.printf("Today is a %s.%n", name); }
From source file:Main.java
public static void main(String args[]) { Calendar now = Calendar.getInstance(); Locale locale = Locale.getDefault(); Map<String, Integer> names = now.getDisplayNames(Calendar.DAY_OF_WEEK, Calendar.LONG, locale); SortedMap<String, Integer> nav = new TreeMap<String, Integer>(names); System.out.printf("Whole list:%n%s%n", nav); System.out.printf("First key: %s\tFirst entry: %s%n", nav.firstKey(), nav.firstEntry()); }