SlideShare a Scribd company logo
Java Dates
Sujit Kumar
Zenolocity LLC
Copyright @
java.util.Date
โ€ข Represents an instant in time
โ€ข Signed long representing number of millisecs
since epoch
โ€ข Epoch based. Epoch is Jan 01, 1970 00:00:00
GMT
โ€ข Date() constructor creates a date object
representing the current time
โ€ข Date(long) constructor creates a date object
representing that time.
System.currentTimeMillis() returns the current
epoch based time.
Date Methods
Comparison Methods:
โ€ข after(Date)
โ€ข before(Date)
โ€ข compareTo(Date)
โ€ข equals(Date)
Note: Lot of deprecated methods in Date. Use
Calendar class and itโ€™s methods instead.
java.sql.Date
โ€ข Java.util.Date is a basic, all-purpose Date object. It
simply stores a Date (as a long) and allows you to
display it.
java.sql.Date extends java.util.Date to add the
following functionality:
1) toString outputs the date as "yyyy-mm-dd" instead
of as a Locale specific String.
2) add the valueOf method to read a String of "yyyymm-dd" format and parse it into a java.sql.Date object.
java.util.Calendar
โ€ข Represents a specific instance in time
โ€ข Abstract class โ€“ itโ€™s concrete derived classes
support different calendar styles.
โ€ข Gregorian Calendar most common
implementation
โ€ข Calendar.getInstance() returns a localized
Calendar object initialized with current date
and time.
Calendar (contdโ€ฆ)
โ€ข set and get each of the date and time fields
like
month, day, year, hour, minutes, seconds, etc.
โ€ข Compare calendar objects using before, after
and compareTo.
โ€ข Date and time arithmetic with the add
method.
โ€ข Use getTime() to convert to a Date object.
java.util.TimeZone
โ€ข Represents a timezone offset, calculates the daylight
savings time as well.
โ€ข TimeZone.getTimeZone() method returns a TimeZone
object based on the systemโ€™s time zone setting.
โ€ข TimeZone.getTimeZone("America/Los_Angeles") to get
the TimeZone object for a specific timezone ID.
โ€ข Invoke the getTimeZone() method on a calendar object
to return the corresponding TimeZone object.
โ€ข Important methods: getId(), getDisplayName() and
getRawOffset()
Format and Parse Dates
โ€ข java.text.DateFormat : abstract class
โ€ข The format(Date) method generates a String
representation of a Date object
โ€ข The parse(String) method generates a Date
object by parsing a date/time string
โ€ข Java.text.SimpleDateFormat โ€“ concrete class
for user defined patterns for formatting &
parsing dates and times.
Thread Safe SimpleDateFormat
โ€ข

SimpleDateFormat is not thread safe.

โ€ข

Here is an implementation to make it thread safe.

public class ThreadSafeSimpleDateFormat {
private DateFormat df;
public ThreadSafeSimpleDateFormat(String format) {
this.df = new SimpleDateFormat(format);
}
public synchronized String format(Date date) {
return df.format(date);
}

}

public synchronized Date parse(String string) throws ParseException {
return df.parse(string);
}
DateFormat Static Methods
โ€ข Static methods to obtain date/time formatters.
โ€ข Based on the default or a specific locale.
โ€ข Examples:
DateFormat.getDateTimeInstance()
DateFormat.getDateInstance(
DateFormat.LONG, Locale.GERMAN)
DateFormat.getTimeInstance(DateFormat.LONG)
Joda-time
โ€ข High quality replacement for the
Java date and time classes.
โ€ข Design allows for
multiple calendar systems, while still providing a
simple API. The 'default' calendar is the
ISO8601 standard which is used by XML.
โ€ข The Gregorian, Julian, Buddhist, Coptic, Ethiopic
and Islamic systems are also included.
โ€ข Supporting classes include time
zone, duration, format and parsing.
โ€ข http://joda-time.sourceforge.net/
Ad

More Related Content

What's hot (18)

Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
injulkarnilesh
ย 
Introduction to Java Strings, By Kavita Ganesan
Introduction to Java Strings, By Kavita GanesanIntroduction to Java Strings, By Kavita Ganesan
Introduction to Java Strings, By Kavita Ganesan
Kavita Ganesan
ย 
RxSubject And Operators
RxSubject And OperatorsRxSubject And Operators
RxSubject And Operators
Seven Peaks Speaks
ย 
Kmeans plusplus
Kmeans plusplusKmeans plusplus
Kmeans plusplus
Renaud Richardet
ย 
Autoboxing And Unboxing In Java
Autoboxing And Unboxing In JavaAutoboxing And Unboxing In Java
Autoboxing And Unboxing In Java
chathuranga kasun bamunusingha
ย 
Java Strings
Java StringsJava Strings
Java Strings
RaBiya Chaudhry
ย 
Ch 7: Object-Oriented JavaScript
Ch 7: Object-Oriented JavaScriptCh 7: Object-Oriented JavaScript
Ch 7: Object-Oriented JavaScript
dcomfort6819
ย 
Viewpic
ViewpicViewpic
Viewpic
Jay-r'vampy Reloaded
ย 
Lesson3
Lesson3Lesson3
Lesson3
Arpan91
ย 
PATTERNS09 - Generics in .NET and Java
PATTERNS09 - Generics in .NET and JavaPATTERNS09 - Generics in .NET and Java
PATTERNS09 - Generics in .NET and Java
Michael Heron
ย 
Chapter 6.3
Chapter 6.3Chapter 6.3
Chapter 6.3
sotlsoc
ย 
String and string buffer
String and string bufferString and string buffer
String and string buffer
kamal kotecha
ย 
Classes1
Classes1Classes1
Classes1
phanleson
ย 
Streaming data to s3 using akka streams
Streaming data to s3 using akka streamsStreaming data to s3 using akka streams
Streaming data to s3 using akka streams
Mikhail Girkin
ย 
CloudClustering: Toward a scalable machine learning toolkit for Windows Azure
CloudClustering: Toward a scalable machine learning toolkit for Windows AzureCloudClustering: Toward a scalable machine learning toolkit for Windows Azure
CloudClustering: Toward a scalable machine learning toolkit for Windows Azure
Ankur Dave
ย 
Java String
Java String Java String
Java String
SATYAM SHRIVASTAV
ย 
C # test paper
C # test paperC # test paper
C # test paper
application developer
ย 
String in java
String in javaString in java
String in java
Ideal Eyes Business College
ย 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
injulkarnilesh
ย 
Introduction to Java Strings, By Kavita Ganesan
Introduction to Java Strings, By Kavita GanesanIntroduction to Java Strings, By Kavita Ganesan
Introduction to Java Strings, By Kavita Ganesan
Kavita Ganesan
ย 
RxSubject And Operators
RxSubject And OperatorsRxSubject And Operators
RxSubject And Operators
Seven Peaks Speaks
ย 
Ch 7: Object-Oriented JavaScript
Ch 7: Object-Oriented JavaScriptCh 7: Object-Oriented JavaScript
Ch 7: Object-Oriented JavaScript
dcomfort6819
ย 
Lesson3
Lesson3Lesson3
Lesson3
Arpan91
ย 
PATTERNS09 - Generics in .NET and Java
PATTERNS09 - Generics in .NET and JavaPATTERNS09 - Generics in .NET and Java
PATTERNS09 - Generics in .NET and Java
Michael Heron
ย 
Chapter 6.3
Chapter 6.3Chapter 6.3
Chapter 6.3
sotlsoc
ย 
String and string buffer
String and string bufferString and string buffer
String and string buffer
kamal kotecha
ย 
Classes1
Classes1Classes1
Classes1
phanleson
ย 
Streaming data to s3 using akka streams
Streaming data to s3 using akka streamsStreaming data to s3 using akka streams
Streaming data to s3 using akka streams
Mikhail Girkin
ย 
CloudClustering: Toward a scalable machine learning toolkit for Windows Azure
CloudClustering: Toward a scalable machine learning toolkit for Windows AzureCloudClustering: Toward a scalable machine learning toolkit for Windows Azure
CloudClustering: Toward a scalable machine learning toolkit for Windows Azure
Ankur Dave
ย 

Viewers also liked (7)

Java enum
Java enumJava enum
Java enum
Sujit Kumar
ย 
Debug a java program
Debug a java programDebug a java program
Debug a java program
Sujit Kumar
ย 
Introduction to java exceptions
Introduction to java exceptionsIntroduction to java exceptions
Introduction to java exceptions
Sujit Kumar
ย 
Java interfaces
Java interfacesJava interfaces
Java interfaces
Sujit Kumar
ย 
Java final keyword
Java final keywordJava final keyword
Java final keyword
Sujit Kumar
ย 
Java Web Development Course
Java Web Development CourseJava Web Development Course
Java Web Development Course
Sujit Kumar
ย 
Java file paths
Java file pathsJava file paths
Java file paths
Sujit Kumar
ย 
Java enum
Java enumJava enum
Java enum
Sujit Kumar
ย 
Debug a java program
Debug a java programDebug a java program
Debug a java program
Sujit Kumar
ย 
Introduction to java exceptions
Introduction to java exceptionsIntroduction to java exceptions
Introduction to java exceptions
Sujit Kumar
ย 
Java interfaces
Java interfacesJava interfaces
Java interfaces
Sujit Kumar
ย 
Java final keyword
Java final keywordJava final keyword
Java final keyword
Sujit Kumar
ย 
Java Web Development Course
Java Web Development CourseJava Web Development Course
Java Web Development Course
Sujit Kumar
ย 
Java file paths
Java file pathsJava file paths
Java file paths
Sujit Kumar
ย 
Ad

Similar to Java dates (20)

Java 8
Java 8Java 8
Java 8
Raghda Salah
ย 
Date class
Date classDate class
Date class
Muthukumaran Subramanian
ย 
Java22_1670144363.pptx
Java22_1670144363.pptxJava22_1670144363.pptx
Java22_1670144363.pptx
DilanAlmsa
ย 
Lecture3.pdf
Lecture3.pdfLecture3.pdf
Lecture3.pdf
SakhilejasonMsibi
ย 
Date object.pptx date and object v
Date object.pptx date and object        vDate object.pptx date and object        v
Date object.pptx date and object v
22x026
ย 
A Quick peek @ New Date & Time API of Java 8
A Quick peek @ New Date & Time API of Java 8A Quick peek @ New Date & Time API of Java 8
A Quick peek @ New Date & Time API of Java 8
Buddha Jyothiprasad
ย 
New Java Date/Time API
New Java Date/Time APINew Java Date/Time API
New Java Date/Time API
Juliet Nkwor
ย 
15. DateTime API.ppt
15. DateTime API.ppt15. DateTime API.ppt
15. DateTime API.ppt
VISHNUSHANKARSINGH3
ย 
Understanding Sitecore Schedulers: Configuration and Execution Guide
Understanding Sitecore Schedulers: Configuration and Execution GuideUnderstanding Sitecore Schedulers: Configuration and Execution Guide
Understanding Sitecore Schedulers: Configuration and Execution Guide
Akshay Barve
ย 
Java 8 Date-Time API
Java 8 Date-Time APIJava 8 Date-Time API
Java 8 Date-Time API
Anindya Bandopadhyay
ย 
Utility classes
Utility classesUtility classes
Utility classes
Icancode
ย 
Java Day-7
Java Day-7Java Day-7
Java Day-7
People Strategists
ย 
U-III Prt-2.pptx0 for Java and hardware coding...
U-III Prt-2.pptx0 for Java and hardware coding...U-III Prt-2.pptx0 for Java and hardware coding...
U-III Prt-2.pptx0 for Java and hardware coding...
zainmkhan20
ย 
WEB222-lecture-4.pptx
WEB222-lecture-4.pptxWEB222-lecture-4.pptx
WEB222-lecture-4.pptx
RohitSharma318779
ย 
Sql server 2016: System Databases, data types, DML, json, and built-in functions
Sql server 2016: System Databases, data types, DML, json, and built-in functionsSql server 2016: System Databases, data types, DML, json, and built-in functions
Sql server 2016: System Databases, data types, DML, json, and built-in functions
Seyed Ibrahim
ย 
Packages and inbuilt classes of java
Packages and inbuilt classes of javaPackages and inbuilt classes of java
Packages and inbuilt classes of java
kamal kotecha
ย 
Jdbc oracle
Jdbc oracleJdbc oracle
Jdbc oracle
yazidds2
ย 
Computer programming 2 Lesson 14
Computer programming 2  Lesson 14Computer programming 2  Lesson 14
Computer programming 2 Lesson 14
MLG College of Learning, Inc
ย 
Class and Object JAVA PROGRAMMING LANG .pdf
Class and Object JAVA PROGRAMMING LANG .pdfClass and Object JAVA PROGRAMMING LANG .pdf
Class and Object JAVA PROGRAMMING LANG .pdf
sameer2543ynr
ย 
J Query Presentation of David
J Query Presentation of DavidJ Query Presentation of David
J Query Presentation of David
Arun David Johnson R
ย 
Java22_1670144363.pptx
Java22_1670144363.pptxJava22_1670144363.pptx
Java22_1670144363.pptx
DilanAlmsa
ย 
Date object.pptx date and object v
Date object.pptx date and object        vDate object.pptx date and object        v
Date object.pptx date and object v
22x026
ย 
A Quick peek @ New Date & Time API of Java 8
A Quick peek @ New Date & Time API of Java 8A Quick peek @ New Date & Time API of Java 8
A Quick peek @ New Date & Time API of Java 8
Buddha Jyothiprasad
ย 
New Java Date/Time API
New Java Date/Time APINew Java Date/Time API
New Java Date/Time API
Juliet Nkwor
ย 
Understanding Sitecore Schedulers: Configuration and Execution Guide
Understanding Sitecore Schedulers: Configuration and Execution GuideUnderstanding Sitecore Schedulers: Configuration and Execution Guide
Understanding Sitecore Schedulers: Configuration and Execution Guide
Akshay Barve
ย 
Utility classes
Utility classesUtility classes
Utility classes
Icancode
ย 
U-III Prt-2.pptx0 for Java and hardware coding...
U-III Prt-2.pptx0 for Java and hardware coding...U-III Prt-2.pptx0 for Java and hardware coding...
U-III Prt-2.pptx0 for Java and hardware coding...
zainmkhan20
ย 
WEB222-lecture-4.pptx
WEB222-lecture-4.pptxWEB222-lecture-4.pptx
WEB222-lecture-4.pptx
RohitSharma318779
ย 
Sql server 2016: System Databases, data types, DML, json, and built-in functions
Sql server 2016: System Databases, data types, DML, json, and built-in functionsSql server 2016: System Databases, data types, DML, json, and built-in functions
Sql server 2016: System Databases, data types, DML, json, and built-in functions
Seyed Ibrahim
ย 
Packages and inbuilt classes of java
Packages and inbuilt classes of javaPackages and inbuilt classes of java
Packages and inbuilt classes of java
kamal kotecha
ย 
Jdbc oracle
Jdbc oracleJdbc oracle
Jdbc oracle
yazidds2
ย 
Class and Object JAVA PROGRAMMING LANG .pdf
Class and Object JAVA PROGRAMMING LANG .pdfClass and Object JAVA PROGRAMMING LANG .pdf
Class and Object JAVA PROGRAMMING LANG .pdf
sameer2543ynr
ย 
J Query Presentation of David
J Query Presentation of DavidJ Query Presentation of David
J Query Presentation of David
Arun David Johnson R
ย 
Ad

More from Sujit Kumar (20)

Introduction to OOP with java
Introduction to OOP with javaIntroduction to OOP with java
Introduction to OOP with java
Sujit Kumar
ย 
SFDC Database Basics
SFDC Database BasicsSFDC Database Basics
SFDC Database Basics
Sujit Kumar
ย 
SFDC Database Security
SFDC Database SecuritySFDC Database Security
SFDC Database Security
Sujit Kumar
ย 
SFDC Social Applications
SFDC Social ApplicationsSFDC Social Applications
SFDC Social Applications
Sujit Kumar
ย 
SFDC Other Platform Features
SFDC Other Platform FeaturesSFDC Other Platform Features
SFDC Other Platform Features
Sujit Kumar
ย 
SFDC Outbound Integrations
SFDC Outbound IntegrationsSFDC Outbound Integrations
SFDC Outbound Integrations
Sujit Kumar
ย 
SFDC Inbound Integrations
SFDC Inbound IntegrationsSFDC Inbound Integrations
SFDC Inbound Integrations
Sujit Kumar
ย 
SFDC UI - Advanced Visualforce
SFDC UI - Advanced VisualforceSFDC UI - Advanced Visualforce
SFDC UI - Advanced Visualforce
Sujit Kumar
ย 
SFDC UI - Introduction to Visualforce
SFDC UI -  Introduction to VisualforceSFDC UI -  Introduction to Visualforce
SFDC UI - Introduction to Visualforce
Sujit Kumar
ย 
SFDC Deployments
SFDC DeploymentsSFDC Deployments
SFDC Deployments
Sujit Kumar
ย 
SFDC Batch Apex
SFDC Batch ApexSFDC Batch Apex
SFDC Batch Apex
Sujit Kumar
ย 
SFDC Data Loader
SFDC Data LoaderSFDC Data Loader
SFDC Data Loader
Sujit Kumar
ย 
SFDC Advanced Apex
SFDC Advanced Apex SFDC Advanced Apex
SFDC Advanced Apex
Sujit Kumar
ย 
SFDC Introduction to Apex
SFDC Introduction to ApexSFDC Introduction to Apex
SFDC Introduction to Apex
Sujit Kumar
ย 
SFDC Database Additional Features
SFDC Database Additional FeaturesSFDC Database Additional Features
SFDC Database Additional Features
Sujit Kumar
ย 
Introduction to SalesForce
Introduction to SalesForceIntroduction to SalesForce
Introduction to SalesForce
Sujit Kumar
ย 
More about java strings - Immutability and String Pool
More about java strings - Immutability and String PoolMore about java strings - Immutability and String Pool
More about java strings - Immutability and String Pool
Sujit Kumar
ย 
Hibernate First and Second level caches
Hibernate First and Second level cachesHibernate First and Second level caches
Hibernate First and Second level caches
Sujit Kumar
ย 
Java equals hashCode Contract
Java equals hashCode ContractJava equals hashCode Contract
Java equals hashCode Contract
Sujit Kumar
ย 
Java Comparable and Comparator
Java Comparable and ComparatorJava Comparable and Comparator
Java Comparable and Comparator
Sujit Kumar
ย 
Introduction to OOP with java
Introduction to OOP with javaIntroduction to OOP with java
Introduction to OOP with java
Sujit Kumar
ย 
SFDC Database Basics
SFDC Database BasicsSFDC Database Basics
SFDC Database Basics
Sujit Kumar
ย 
SFDC Database Security
SFDC Database SecuritySFDC Database Security
SFDC Database Security
Sujit Kumar
ย 
SFDC Social Applications
SFDC Social ApplicationsSFDC Social Applications
SFDC Social Applications
Sujit Kumar
ย 
SFDC Other Platform Features
SFDC Other Platform FeaturesSFDC Other Platform Features
SFDC Other Platform Features
Sujit Kumar
ย 
SFDC Outbound Integrations
SFDC Outbound IntegrationsSFDC Outbound Integrations
SFDC Outbound Integrations
Sujit Kumar
ย 
SFDC Inbound Integrations
SFDC Inbound IntegrationsSFDC Inbound Integrations
SFDC Inbound Integrations
Sujit Kumar
ย 
SFDC UI - Advanced Visualforce
SFDC UI - Advanced VisualforceSFDC UI - Advanced Visualforce
SFDC UI - Advanced Visualforce
Sujit Kumar
ย 
SFDC UI - Introduction to Visualforce
SFDC UI -  Introduction to VisualforceSFDC UI -  Introduction to Visualforce
SFDC UI - Introduction to Visualforce
Sujit Kumar
ย 
SFDC Deployments
SFDC DeploymentsSFDC Deployments
SFDC Deployments
Sujit Kumar
ย 
SFDC Batch Apex
SFDC Batch ApexSFDC Batch Apex
SFDC Batch Apex
Sujit Kumar
ย 
SFDC Data Loader
SFDC Data LoaderSFDC Data Loader
SFDC Data Loader
Sujit Kumar
ย 
SFDC Advanced Apex
SFDC Advanced Apex SFDC Advanced Apex
SFDC Advanced Apex
Sujit Kumar
ย 
SFDC Introduction to Apex
SFDC Introduction to ApexSFDC Introduction to Apex
SFDC Introduction to Apex
Sujit Kumar
ย 
SFDC Database Additional Features
SFDC Database Additional FeaturesSFDC Database Additional Features
SFDC Database Additional Features
Sujit Kumar
ย 
Introduction to SalesForce
Introduction to SalesForceIntroduction to SalesForce
Introduction to SalesForce
Sujit Kumar
ย 
More about java strings - Immutability and String Pool
More about java strings - Immutability and String PoolMore about java strings - Immutability and String Pool
More about java strings - Immutability and String Pool
Sujit Kumar
ย 
Hibernate First and Second level caches
Hibernate First and Second level cachesHibernate First and Second level caches
Hibernate First and Second level caches
Sujit Kumar
ย 
Java equals hashCode Contract
Java equals hashCode ContractJava equals hashCode Contract
Java equals hashCode Contract
Sujit Kumar
ย 
Java Comparable and Comparator
Java Comparable and ComparatorJava Comparable and Comparator
Java Comparable and Comparator
Sujit Kumar
ย 

Recently uploaded (20)

Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
ย 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
ย 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
ย 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
ย 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
ย 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
ย 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
ย 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
ย 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
ย 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
ย 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
ย 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
ย 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
ย 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
ย 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
ย 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
ย 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
ย 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
ย 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
ย 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
ย 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
ย 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
ย 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
ย 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
ย 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
ย 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
ย 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
ย 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
ย 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
ย 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
ย 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
ย 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
ย 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
ย 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
ย 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
ย 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
ย 

Java dates

  • 2. java.util.Date โ€ข Represents an instant in time โ€ข Signed long representing number of millisecs since epoch โ€ข Epoch based. Epoch is Jan 01, 1970 00:00:00 GMT โ€ข Date() constructor creates a date object representing the current time โ€ข Date(long) constructor creates a date object representing that time. System.currentTimeMillis() returns the current epoch based time.
  • 3. Date Methods Comparison Methods: โ€ข after(Date) โ€ข before(Date) โ€ข compareTo(Date) โ€ข equals(Date) Note: Lot of deprecated methods in Date. Use Calendar class and itโ€™s methods instead.
  • 4. java.sql.Date โ€ข Java.util.Date is a basic, all-purpose Date object. It simply stores a Date (as a long) and allows you to display it. java.sql.Date extends java.util.Date to add the following functionality: 1) toString outputs the date as "yyyy-mm-dd" instead of as a Locale specific String. 2) add the valueOf method to read a String of "yyyymm-dd" format and parse it into a java.sql.Date object.
  • 5. java.util.Calendar โ€ข Represents a specific instance in time โ€ข Abstract class โ€“ itโ€™s concrete derived classes support different calendar styles. โ€ข Gregorian Calendar most common implementation โ€ข Calendar.getInstance() returns a localized Calendar object initialized with current date and time.
  • 6. Calendar (contdโ€ฆ) โ€ข set and get each of the date and time fields like month, day, year, hour, minutes, seconds, etc. โ€ข Compare calendar objects using before, after and compareTo. โ€ข Date and time arithmetic with the add method. โ€ข Use getTime() to convert to a Date object.
  • 7. java.util.TimeZone โ€ข Represents a timezone offset, calculates the daylight savings time as well. โ€ข TimeZone.getTimeZone() method returns a TimeZone object based on the systemโ€™s time zone setting. โ€ข TimeZone.getTimeZone("America/Los_Angeles") to get the TimeZone object for a specific timezone ID. โ€ข Invoke the getTimeZone() method on a calendar object to return the corresponding TimeZone object. โ€ข Important methods: getId(), getDisplayName() and getRawOffset()
  • 8. Format and Parse Dates โ€ข java.text.DateFormat : abstract class โ€ข The format(Date) method generates a String representation of a Date object โ€ข The parse(String) method generates a Date object by parsing a date/time string โ€ข Java.text.SimpleDateFormat โ€“ concrete class for user defined patterns for formatting & parsing dates and times.
  • 9. Thread Safe SimpleDateFormat โ€ข SimpleDateFormat is not thread safe. โ€ข Here is an implementation to make it thread safe. public class ThreadSafeSimpleDateFormat { private DateFormat df; public ThreadSafeSimpleDateFormat(String format) { this.df = new SimpleDateFormat(format); } public synchronized String format(Date date) { return df.format(date); } } public synchronized Date parse(String string) throws ParseException { return df.parse(string); }
  • 10. DateFormat Static Methods โ€ข Static methods to obtain date/time formatters. โ€ข Based on the default or a specific locale. โ€ข Examples: DateFormat.getDateTimeInstance() DateFormat.getDateInstance( DateFormat.LONG, Locale.GERMAN) DateFormat.getTimeInstance(DateFormat.LONG)
  • 11. Joda-time โ€ข High quality replacement for the Java date and time classes. โ€ข Design allows for multiple calendar systems, while still providing a simple API. The 'default' calendar is the ISO8601 standard which is used by XML. โ€ข The Gregorian, Julian, Buddhist, Coptic, Ethiopic and Islamic systems are also included. โ€ข Supporting classes include time zone, duration, format and parsing. โ€ข http://joda-time.sourceforge.net/