I have been writing some toy programs to relearn my Java skills. This time around I decided to write a calendar app. Nothing fancy mind you. I just put out a text calendar to the console.
Initially I had visions of computing all kinds of dates. I thought I could start with a known day falling on a certain day of the week. Then I could compute all relative dates with some formulas. Sure I would have to deal with leap years and such. But that would be a great project.
I found that the Calendar class in java.util was almost all I needed. No need to compute the day of the week the first day of the month falls on. I just set up a Calendar object with that date. Then I interrogate it to figure out which day of the week it is. Same thing with determining the number of days in a month.
This exercise was quite useful. I got some practice. I also learned some details of a new class. Calendar feels like a nice API. You just have to learn some of its constants. Then you can get() or set() to your heart's content. I banged out my calendar app in about 50 lines of code. Given that I am a bit wordy with my code, that is not too shabby.
Reproducing a Race Condition
-
We have a job at work that runs every Wednesday night. All of a sudden, it
aborted the last 2 weeks. This caused some critical data to be late. The
main ...
2 years ago