Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures

Home

Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips

Books

Submit News
Search the site here...
Search...
 
Search the JavaFAQ.nu
1000 Java Tips ebook

1000 Java Tips - Click here for the high resolution copy!1000 Java Tips - Click here for the high resolution copy!

Java Screensaver, take it here

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java programming articles and tips. Please take your copy here.

Take your copy of free "Java Technology Screensaver"!.

How do I compare two dates and times, date between dates, time between times and

JavaFAQ Home » General Java Go to all tips in General Java


Bookmark and Share

Question: How do I compare two dates and times, date between dates and so on.

Answer: Almost every month in my daily Java programming work I have this problem - to compare two or many dates or times.

Dates, Calendars are not an easy task to work with. Simple example: never do assume that all the days are 24 hours long. They are not. Some days are 25 and some 23 hours. Seems simple and obvious? Actually not. Most of people forget about it and get troubles twice a year Smile

I collected more than 50 different only working Java code examples with Date class: everything from time, day, month, date, calendar to time synchronizing on computers by Java program (time servers and clients even). In the examples below you can see how this functionality can be used in different areas - applets, files, sound, beans, databases.

Sixth months ago the new section was started on this site - "Only working Java Code Examples". All the examples are grouped by Java technology (J2EE, J2SE, J2ME, etc.) and can be searched by powerful search engine of the site.

Look at all described above code examples here:

Date / Time Example
Calendar Example
Month View
Getting and Setting the Modification Time of a File or Directory
Beep / Date Example
Java Statement Runner
Trivial class to show use of Date & Calendar objects
Show dates before 1970, in JDK1.0/1.1 when Date was broken
Show some date uses
Create SimpleDateFormats from a string read from a file
DateDiff -- compute the difference between two dates
Compare Dates
An Applet to display the current time
The Date we are about to format
Read a file of reminders, run each when due using java.util.Timer
Time Server
Time Client
Time Server
UDP Time Client
Daytime Server
Dayclient and Dayserver - implement the Unix 'daytime' protocol.
Calendar Hack
Try Date Format - enter a time value and a SimpleDateFormat specification.
Last 24 (retrieves file if it's modified since ...)
Clock Label
Clock Label Test
Big Example

And more examples here-> Date and here Calendar

 


 Printer Friendly Page  Printer Friendly Page
 Send to a Friend  Send to a Friend

Bookmark and Share

Search here again if you need more info!
Custom Search




Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

RSS feed Java FAQ RSS feed Java FAQ News     

    RSS feed Java Forums RSS feed Java Forums

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

Interactive software released under GNU GPL, Code Credits, Privacy Policy