Java Date Posted on: December 18, 2008 By Deepak Kumar
In this section we have presented a simple Date example that shows how you can use different constructors of Date.
Java Date
Simple Date example In this section we have presented a simple Date example
that shows how you can use different constructors of Date. We can construct the
Date class in a number of ways.
Comparing two Dates in Java In this example we are going to compare two date
objects using java.util.Date class. For comparing dates, we will be using compareTo()
method.
Comparing two Dates in Java with the use of after method In this example we are going to compare two date
objects in Java programming language. For comparing the date objects we can use after()
method of the java.util.Date class.
Comparing two Dates in Java with the use of before method In the previous example of comparing dates you have
seen how to use after(
) method in java class for comparing two dates. In
this example we are going to compare two date objects with the use of
java.util.Date class.
Getting date by time In this example of creating date using the timestamp
value. We can pass the timestamp value as constructor parameter while creating
the object of java.util.Date().
Getting time in Milliseconds In the previous examples of Date class we have created
simple Date and now in this section we are going to get the current
date and time in the milliseconds.
Simple date formatter example In this section of simple date formatter example we are
going to describe you how you can use different constructors of SimpleDateFormat
class to convert the date into the specified format.
Example program to get all the
available time zones
In this section we show you have to get all the
available time zones using java program. This example is very simple
java code that will list all the available time zones.
Time Format Example
This example shows how to format time using Format class. In this program we use a pattern of special characters to time format.
TimeZone Format Example
This example shows how to format time zone using Format class. In this program we use a pattern of special characters to time format.
Second Format Example
This example shows how to format second using Format class. In this program we use a pattern of special characters to time format.
Minutes Format Example
This example shows how to format minute using Format class. In this program we use a pattern of special characters to time format.
Parsing Date Example
This example shows how to parsing date using Format class. In this program we use a pattern of special characters to time format.
This example shows how to parsing date and time using Format class. In this program we use a pattern of special characters to time format.
Day Format Example
This example shows how to format day using Format class. In this program we use a pattern of special characters to day format.
Week Days Format Example
This example shows how to format week days using Format class. In this program we use a pattern of special characters to format week day.
Month Format Example
This example shows how to format Month using Format class. In this program we use a pattern of special characters to Month format.
Year Format Example
This example shows how to format Year using Format class. In this program we use a pattern of special characters to format week day.
Formatting Date for a Locale Example
This example shows how to format Date using SimpleDateFormat class. In this program we are format date
for different locales.
Hour Format Example
This example shows how to format hour using Format class. In this program we use a pattern of special characters to time format.
Date Format Example
This example shows how to format Date using Format class. In this program we use
a pattern of special characters to date and time format.
Java Time Zone Example In this section we have written a java program which
will take two Time Zone IDs as its argument and then convert the time between
provided time zone IDs.
Adding time span example In this example java program we have added the two time
spans with the use of add() method of Calendar class which is available
in the java.util package.
Java Subtracting Time Span In this example java program we have subtracted
the two time spans with the use of add() method of Calendar class which
is available in the java.util package.
Java Set Default Locale Locale can be set also in our java programs by using
the method setDefault() of Locale class. In this example we have set the
default locale value of our Locale with the Locale.ITALY.
Rolling Time Span in Java In the previous example of adding and subtracting time
span we have added and subtracted the time spans accordingly and since add()
method automatically do the rolling according to the calendar.
Java Date Examples In this section we will be getting the astrological
sign according to the inserted birth date by the user. To get the astrological
sign first we require to have a date object which will be providing the inserted
date by the user.
Ask Questions? Discuss: Java Date View All Comments
Post your Comment