- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Determine day of week in month from Gregorian Calendar in Java
To work with the GregorianCalendar class, import the following package −
import java.util.GregorianCalendar;
To get the day of week in month, use the following field −
cal.get(Calendar.DAY_OF_WEEK_IN_MONTH)
Above, cal is the GregorianCalendar object we created before −
GregorianCalendar cal = new GregorianCalendar();
The following is an example −
Example
import java.util.GregorianCalendar; import java.util.Calendar; import java.util.Date; public class Demo { public static void main(String[] args) { GregorianCalendar cal = new GregorianCalendar(); // date information System.out.println("Date Information.........."); System.out.println("Year = " + cal.get(Calendar.YEAR)); System.out.println("Month = " + (cal.get(Calendar.MONTH) + 1)); System.out.println("Date = " + cal.get(Calendar.DATE)); // week System.out.println("Day of Week in month = " + cal.get(Calendar.DAY_OF_WEEK_IN_MONTH)); } }
Output
Date Information.......... Year = 2018 Month = 11 Date = 19 Day of Week in month = 3
- Related Articles
- Gregorian Calendar in Java
- Display Day Name of Week using Java Calendar
- Get week of month and year using Java Calendar
- Finding day of week from date (day, month, year) in JavaScript
- Specify the TimeZone explicitly for Gregorian Calendar in Java
- Java Program to get day of week for the last day of each month in 2019
- Set the Date and Time with Gregorian Calendar in Java
- Get Day Number of Week in Java
- How to set the first day of the week in sap.m.DatePicker's calendar?
- Display Month of Year using Java Calendar
- Calendar Functions in Python - ( calendar(), month(), isleap()?)
- Convert day of year to day of month in Java
- Formatting day of week using SimpleDateFormat in Java
- Formatting day of week in EEEE format in Java
- How to get day of month, day of year and day of week in android using offset date time API class?

Advertisements