A Tutorial covering the basics of Java Calendar and Date Manipulation
“Let us tenderly and kindly cherish therefore, the means of knowledge. Let us dare to read, think, speak, and write .”
― John Adams
Java provides a Calendarclass for performing data manipulation. A closely related class is the Date class, used to represent a specific instant in time starting from epoch (January 1, 1970 00:00:00.000 GMT). Let use learn how we can use these two classes for date and time manipulation.
Learn how to use the Timer and the TimerTask classes to implement simple task scheduling for your application.
“Humor is reason gone mad.”
― Groucho Marx
Scheduling tasks to run is a need which sometimes arises in a java program. Maybe you want to run periodic cleanup of some resource. Or check on the status of some job. Or maybe fetch a URL which might not be available the first time.
We can parse and format dates in Java easily with the SimpleDateFormatclass. It is similar to using the POSIX function strftime() in C/C++ with a few gotchas. Let us learn the proper usage of SimpleDateFormat and delve into some of its issues.