SlideShare a Scribd company logo
1 of 10
JAVA CALENDAR
-:Presented by:-
Yallappa Gadadi
JAVA CALENDAR CLASS
 Java Calendar class is an abstract class that provides
methods for converting date between a specific instant
in time and a set of calendar fields such as MONTH,
YEAR, HOUR, etc.
 It inherits Object class and implements the Comparable
interface.
JAVA CALENDAR CLASS DECLARATION
 Let's see the declaration of java.util.Calendar class.
public abstract class Calendar extends Object
implements Serializable, Cloneable, Comparable<Calendar>
METHODS OF JAVA CALENDAR
Method Description
int get(int field) It is used to return the value of
the given calendar field.
static Calendar
getInstance()
It is used to get a calendar
using the default time zone and
locale.
abstract int
getMaximum(int field)
It is used to return the maximum
value for the given calendar
field of this Calendar instance.
abstract int
getMinimum(int field)
It is used to return the minimum
value for the given calendar
field of this Calendar instance.
JAVA CALENDAR CLASS EXAMPLE
import java.util.Calendar;
public class CalendarExample1
{
public static void main(String[] args)
{
Calendar calendar = Calendar.getInstance();
System.out.println("The current date is : " + calendar.getTime());
}
}
JAVA CALENDAR CLASS EXAMPLE: GET()
import java.util.*;
public class CalendarExample2{
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
System.out.println("At present Calendar's Year: " +
calendar.get(Calendar.YEAR));
System.out.println("At present Calendar's Day: " +
calendar.get(Calendar.DATE));
}
}
JAVA CALENDAR CLASS EXAMPLE: GETINSTANCE()
import java.util.*;
public class CalendarExample3
{
public static void main(String[] args)
{
Calendar calendar = Calendar.getInstance();
System.out.print("At present Date And Time Is: " +
calendar.getTime());
}
}
JAVA CALENDAR CLASS EXAMPLE: GETMAXIMUM()
import java.util.*;
public class CalendarExample4 {
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
int maximum = calendar.getMaximum(Calendar.DAY_OF_WEEK)
;
System.out.println("Maximum number of days in week: " + max
imum);
maximum = calendar.getMaximum(Calendar.WEEK_OF_YEAR);
System.out.println("Maximum number of weeks in year: " + ma
ximum);
}
}
JAVA CALENDAR CLASS EXAMPLE: GETMINIMUM()
import java.util.*;
public class CalendarExample5 {
public static void main(String[] args) {
Calendar cal = Calendar.getInstance();
int maximum = cal.getMinimum(Calendar.DAY_OF_WEEK);
System.out.println("Minimum number of days in week: " + maxi
mum);
maximum = cal.getMinimum(Calendar.WEEK_OF_YEAR);
System.out.println("Minimum number of weeks in year: " + maxi
mum);
}
}
Java calendar

More Related Content

What's hot

What's hot (20)

07 java collection
07 java collection07 java collection
07 java collection
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
 
Spark introduction and architecture
Spark introduction and architectureSpark introduction and architecture
Spark introduction and architecture
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
Apache Spark Data Source V2 with Wenchen Fan and Gengliang Wang
Apache Spark Data Source V2 with Wenchen Fan and Gengliang WangApache Spark Data Source V2 with Wenchen Fan and Gengliang Wang
Apache Spark Data Source V2 with Wenchen Fan and Gengliang Wang
 
Java I/O
Java I/OJava I/O
Java I/O
 
Java collections concept
Java collections conceptJava collections concept
Java collections concept
 
Asp.net.
Asp.net.Asp.net.
Asp.net.
 
Generics in java
Generics in javaGenerics in java
Generics in java
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
standard template library(STL) in C++
standard template library(STL) in C++standard template library(STL) in C++
standard template library(STL) in C++
 
Java Applets
Java AppletsJava Applets
Java Applets
 
Arbitrary Stateful Aggregations using Structured Streaming in Apache Spark
Arbitrary Stateful Aggregations using Structured Streaming in Apache SparkArbitrary Stateful Aggregations using Structured Streaming in Apache Spark
Arbitrary Stateful Aggregations using Structured Streaming in Apache Spark
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
 
Event Handling in Java
Event Handling in JavaEvent Handling in Java
Event Handling in Java
 
jQuery PPT
jQuery PPTjQuery PPT
jQuery PPT
 
Beyond SQL: Speeding up Spark with DataFrames
Beyond SQL: Speeding up Spark with DataFramesBeyond SQL: Speeding up Spark with DataFrames
Beyond SQL: Speeding up Spark with DataFrames
 
Difference between snowflake schema and fact constellation
Difference between snowflake schema and fact constellationDifference between snowflake schema and fact constellation
Difference between snowflake schema and fact constellation
 

Similar to Java calendar

Java programs
Java programsJava programs
Java programs
jojeph
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...
MaruMengesha
 
Description (Part A) In this lab you will write a Queue implementati.pdf
Description (Part A) In this lab you will write a Queue implementati.pdfDescription (Part A) In this lab you will write a Queue implementati.pdf
Description (Part A) In this lab you will write a Queue implementati.pdf
rishabjain5053
 

Similar to Java calendar (20)

Java22_1670144363.pptx
Java22_1670144363.pptxJava22_1670144363.pptx
Java22_1670144363.pptx
 
Java programs
Java programsJava programs
Java programs
 
Packages and inbuilt classes of java
Packages and inbuilt classes of javaPackages and inbuilt classes of java
Packages and inbuilt classes of java
 
CS2309 JAVA LAB MANUAL
CS2309 JAVA LAB MANUALCS2309 JAVA LAB MANUAL
CS2309 JAVA LAB MANUAL
 
Object - Based Programming
Object - Based ProgrammingObject - Based Programming
Object - Based Programming
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
 
Chap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptxChap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptx
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...
 
Effective Java. By materials of Josch Bloch's book
Effective Java. By materials of Josch Bloch's bookEffective Java. By materials of Josch Bloch's book
Effective Java. By materials of Josch Bloch's book
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
 
Java8 features
Java8 featuresJava8 features
Java8 features
 
15. DateTime API.ppt
15. DateTime API.ppt15. DateTime API.ppt
15. DateTime API.ppt
 
Test program
Test programTest program
Test program
 
Java Reflection Concept and Working
Java Reflection Concept and WorkingJava Reflection Concept and Working
Java Reflection Concept and Working
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes
 
Csphtp1 08
Csphtp1 08Csphtp1 08
Csphtp1 08
 
Advanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAdvanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sir
 
Description (Part A) In this lab you will write a Queue implementati.pdf
Description (Part A) In this lab you will write a Queue implementati.pdfDescription (Part A) In this lab you will write a Queue implementati.pdf
Description (Part A) In this lab you will write a Queue implementati.pdf
 
V33 date function-c
V33  date function-cV33  date function-c
V33 date function-c
 

Recently uploaded

會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 

Recently uploaded (20)

The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 

Java calendar

  • 2. JAVA CALENDAR CLASS  Java Calendar class is an abstract class that provides methods for converting date between a specific instant in time and a set of calendar fields such as MONTH, YEAR, HOUR, etc.  It inherits Object class and implements the Comparable interface.
  • 3. JAVA CALENDAR CLASS DECLARATION  Let's see the declaration of java.util.Calendar class. public abstract class Calendar extends Object implements Serializable, Cloneable, Comparable<Calendar>
  • 4. METHODS OF JAVA CALENDAR Method Description int get(int field) It is used to return the value of the given calendar field. static Calendar getInstance() It is used to get a calendar using the default time zone and locale. abstract int getMaximum(int field) It is used to return the maximum value for the given calendar field of this Calendar instance. abstract int getMinimum(int field) It is used to return the minimum value for the given calendar field of this Calendar instance.
  • 5. JAVA CALENDAR CLASS EXAMPLE import java.util.Calendar; public class CalendarExample1 { public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); System.out.println("The current date is : " + calendar.getTime()); } }
  • 6. JAVA CALENDAR CLASS EXAMPLE: GET() import java.util.*; public class CalendarExample2{ public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); System.out.println("At present Calendar's Year: " + calendar.get(Calendar.YEAR)); System.out.println("At present Calendar's Day: " + calendar.get(Calendar.DATE)); } }
  • 7. JAVA CALENDAR CLASS EXAMPLE: GETINSTANCE() import java.util.*; public class CalendarExample3 { public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); System.out.print("At present Date And Time Is: " + calendar.getTime()); } }
  • 8. JAVA CALENDAR CLASS EXAMPLE: GETMAXIMUM() import java.util.*; public class CalendarExample4 { public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); int maximum = calendar.getMaximum(Calendar.DAY_OF_WEEK) ; System.out.println("Maximum number of days in week: " + max imum); maximum = calendar.getMaximum(Calendar.WEEK_OF_YEAR); System.out.println("Maximum number of weeks in year: " + ma ximum); } }
  • 9. JAVA CALENDAR CLASS EXAMPLE: GETMINIMUM() import java.util.*; public class CalendarExample5 { public static void main(String[] args) { Calendar cal = Calendar.getInstance(); int maximum = cal.getMinimum(Calendar.DAY_OF_WEEK); System.out.println("Minimum number of days in week: " + maxi mum); maximum = cal.getMinimum(Calendar.WEEK_OF_YEAR); System.out.println("Minimum number of weeks in year: " + maxi mum); } }