November 2006
Intermediate to advanced
224 pages
3h 29m
English
Calendar cal = Calendar.getInstance(); System.out.println("Day of week: " + cal.get(Calendar.DAY_OF_WEEK)); System.out.println("Month: " + cal.get(Calendar.MONTH)); System.out.println("Year: " + cal.get(Calendar.YEAR)); System.out.println("Week number: " + cal.get(Calendar.WEEK_OF_YEAR)); |
You can easily determine values such as the day of the week, the month, the year, the week number, and more using the Calendar object’s get() method. In this phrase, we get a Calendar object representing the current date and time using the getInstance() method. We then print out the day of the week, the month, the year, and the week of the year by using the get() method and passing the appropriate Calendar constant ...