2
Most read
5
Most read
7
Most read
Java.util packages
Date
● The java.util.Date class represents a specific
instant in time, with millisecond precision.
● Most of the methods in the class are
deprecated in favor of the java.util.Calendar
class.
● Date d = new Date();
Constructors in java
Constructor Description
Date() This constructor allocates a date object
and initializes it so that it represents the
time at which was allocated, measured to
the nearest milliseconds
Date(long date) This constructor allocates a Date object
and initializes it to represent the specified
number of milliseconds since the
standard base time known as “the epoch”,
namely january 1,1940, 00:00:00 GMT
Methods in Date class
Method Description
Boolean after(Date when) This method tests if this date is after the
specified date
Boolean before(Date when) This method tests if this date is before the
specified date
Object clone() This method return a copy of this object.
Int compareTo(date anotherDate) This method compares two dates for
ordering
Boolean equals(object obj) This method compares two dates for
equality
Long getTime() This method returns the number of
milliseconds since january 1, 1970,
00:00:00 GMT represneted by this Date
object.
Int hasCode() This method returns a hash code value
for this object
Void setTime(long time) This method sets this Date object to
represent a point in time that is time
milliseconds after january 1, 1970
Cont'd
Methods Description
String toString() This method converts this Date object to
string of the form
Date format codes
Sample code for Date
package day5;
import java.util.Date;
public class DateClass
{
public static void main(String[] args)
{
Date d = new Date();
System.out.println(d);
}
}
Output :
Tue Jul 01 11:30:18 IST 2014
Code for comparing dates
Sample output
Parsing string to date
Sample output
Any queries?
Thank you

More Related Content

PPTX
Clusters techniques
PPTX
Clustering in Data Mining
PPTX
Inter Process Communication
PPTX
Event handling
PPTX
PPTX
Network layer - design Issues
PPTX
SQL, Embedded SQL, Dynamic SQL and SQLJ
PPTX
GUI components in Java
Clusters techniques
Clustering in Data Mining
Inter Process Communication
Event handling
Network layer - design Issues
SQL, Embedded SQL, Dynamic SQL and SQLJ
GUI components in Java

What's hot (20)

PPTX
All data models in dbms
PPTX
Concurrency control
PPTX
Recurrent Neural Networks (RNNs)
PPTX
Data Integration and Transformation in Data mining
PPTX
Multimedia Database
PPTX
Data mining primitives
PPTX
Data mining: Classification and prediction
PPTX
Normal forms
PPTX
8 queens problem using back tracking
PPTX
File system vs DBMS
PPTX
joins in database
PPTX
K-Means Clustering Algorithm.pptx
PPTX
Elements of dynamic programming
PPTX
Data cubes
PPTX
Java swing
PPTX
Data-Intensive Technologies for Cloud Computing
PPTX
Data cube computation
PPTX
Purpose of DBMS and users of DBMS
PPTX
Distributed computing
All data models in dbms
Concurrency control
Recurrent Neural Networks (RNNs)
Data Integration and Transformation in Data mining
Multimedia Database
Data mining primitives
Data mining: Classification and prediction
Normal forms
8 queens problem using back tracking
File system vs DBMS
joins in database
K-Means Clustering Algorithm.pptx
Elements of dynamic programming
Data cubes
Java swing
Data-Intensive Technologies for Cloud Computing
Data cube computation
Purpose of DBMS and users of DBMS
Distributed computing
Ad

Similar to Date class (20)

PPTX
Java dates
PDF
Calendar class in java
PDF
Timer class in java
PPTX
Java22_1670144363.pptx
PPTX
Java Arrays and DateTime Functions
PPTX
Computer programming 2 Lesson 14
PPTX
A Quick peek @ New Date & Time API of Java 8
ODP
Multithreading Concepts
PDF
ThreeTen
DOCX
Cis 355 i lab 3 of 6
PDF
Dates and Times in Java 7 and Java 8
PDF
Lecture3.pdf
PPT
Utility classes
PPTX
More topics on Java
PPT
02._Object-Oriented_Programming_Concepts.ppt
PPT
PPT
packages and interfaces
PPT
15. DateTime API.ppt
PPS
Packages and inbuilt classes of java
PPTX
Classes, Objects and Method - Object Oriented Programming with Java
Java dates
Calendar class in java
Timer class in java
Java22_1670144363.pptx
Java Arrays and DateTime Functions
Computer programming 2 Lesson 14
A Quick peek @ New Date & Time API of Java 8
Multithreading Concepts
ThreeTen
Cis 355 i lab 3 of 6
Dates and Times in Java 7 and Java 8
Lecture3.pdf
Utility classes
More topics on Java
02._Object-Oriented_Programming_Concepts.ppt
packages and interfaces
15. DateTime API.ppt
Packages and inbuilt classes of java
Classes, Objects and Method - Object Oriented Programming with Java
Ad

More from Muthukumaran Subramanian (18)

PPTX
Struts introduction
PDF
Operators in java
PDF
Threads concept in java
PDF
StringTokenizer in java
PDF
Overriding methods
PDF
Oops (inheritance&interface)
PDF
Non access modifiers
PDF
Jdbc connectivity in java
PDF
Garbage collection in java
PDF
PDF
Exception handling
PDF
Currency class
PDF
Classes and objects in java
PDF
intorduction to Arrays in java
PDF
Access modifiers in java
PDF
Abstract classes
PDF
Java introduction
PDF
Collections and generics
Struts introduction
Operators in java
Threads concept in java
StringTokenizer in java
Overriding methods
Oops (inheritance&interface)
Non access modifiers
Jdbc connectivity in java
Garbage collection in java
Exception handling
Currency class
Classes and objects in java
intorduction to Arrays in java
Access modifiers in java
Abstract classes
Java introduction
Collections and generics

Recently uploaded (20)

PDF
LEARNERS WITH ADDITIONAL NEEDS ProfEd Topic
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PDF
MICROENCAPSULATION_NDDS_BPHARMACY__SEM VII_PCI .pdf
DOCX
Cambridge-Practice-Tests-for-IELTS-12.docx
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PDF
Empowerment Technology for Senior High School Guide
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PDF
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PDF
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 2).pdf
PDF
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
PDF
Journal of Dental Science - UDMY (2021).pdf
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
PDF
Mucosal Drug Delivery system_NDDS_BPHARMACY__SEM VII_PCI.pdf
PDF
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
LEARNERS WITH ADDITIONAL NEEDS ProfEd Topic
Unit 4 Computer Architecture Multicore Processor.pptx
MICROENCAPSULATION_NDDS_BPHARMACY__SEM VII_PCI .pdf
Cambridge-Practice-Tests-for-IELTS-12.docx
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
Empowerment Technology for Senior High School Guide
What if we spent less time fighting change, and more time building what’s rig...
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 2).pdf
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
FORM 1 BIOLOGY MIND MAPS and their schemes
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
Journal of Dental Science - UDMY (2021).pdf
Environmental Education MCQ BD2EE - Share Source.pdf
Mucosal Drug Delivery system_NDDS_BPHARMACY__SEM VII_PCI.pdf
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
Paper A Mock Exam 9_ Attempt review.pdf.

Date class

  • 2. Date ● The java.util.Date class represents a specific instant in time, with millisecond precision. ● Most of the methods in the class are deprecated in favor of the java.util.Calendar class. ● Date d = new Date();
  • 3. Constructors in java Constructor Description Date() This constructor allocates a date object and initializes it so that it represents the time at which was allocated, measured to the nearest milliseconds Date(long date) This constructor allocates a Date object and initializes it to represent the specified number of milliseconds since the standard base time known as “the epoch”, namely january 1,1940, 00:00:00 GMT
  • 4. Methods in Date class Method Description Boolean after(Date when) This method tests if this date is after the specified date Boolean before(Date when) This method tests if this date is before the specified date Object clone() This method return a copy of this object. Int compareTo(date anotherDate) This method compares two dates for ordering Boolean equals(object obj) This method compares two dates for equality Long getTime() This method returns the number of milliseconds since january 1, 1970, 00:00:00 GMT represneted by this Date object. Int hasCode() This method returns a hash code value for this object Void setTime(long time) This method sets this Date object to represent a point in time that is time milliseconds after january 1, 1970
  • 5. Cont'd Methods Description String toString() This method converts this Date object to string of the form
  • 7. Sample code for Date package day5; import java.util.Date; public class DateClass { public static void main(String[] args) { Date d = new Date(); System.out.println(d); } } Output : Tue Jul 01 11:30:18 IST 2014