CMPS 134 Fall 2019
Programming Assignment #4: Calendar Date Conversions
Due: 11:59pm, Sunday, October 13

Background

FormatExample 1Example 2
mm/dd/yyyy10/8/201905/23/1966
yyyy-mm-dd2019-10-081966-5-23
dd-mm-yyyy08-10-201923-5-1966
dd-Mon-yyyy8-Oct-201923-May-1966
Month day, yearOctober 08, 2019May 23, 1966
day Month year8 October 201923 May 1966
Calendar dates are expressed using several different formats. Here, we consider the 8-digit, or yyyymmdd, format to be "canonical". Examples are 20191008 (year: 2019, month: 10, day: 8) and 19850323. We will be concerned with six other calendar date formats, as illustrated to the right. Except in the canonical form (which always has eight digits), padding month and day numbers less than ten with a leading zero is optional, as suggested by the examples.

Specification

You are given three Java classes, the second of which you are to complete.

Sample Dialog

Enter a calendar date:>8/14/1985
mm/dd/yyyy      "19850814"
dd-mm-yyyy      Exception!!!
yyyy-mm-dd      Exception!!!
dd-Mon-yyyy     Exception!!!
Month day, year Exception!!!
day Month year  Exception!!!

Enter a calendar date:>09-13-2010
mm/dd/yyyy      Exception!!!
dd-mm-yyyy      "20101309"
yyyy-mm-dd      "0009132010"
dd-Mon-yyyy     "20100009"
Month day, year Exception!!!
day Month year  Exception!!!

Enter a calendar date:>14 November 1994
mm/dd/yyyy      Exception!!!
dd-mm-yyyy      Exception!!!
yyyy-mm-dd      Exception!!!
dd-Mon-yyyy     Exception!!!
Month day, year Exception!!!
day Month year  "19941114"

Enter a calendar date:>
Done!
To the right is a sample user/program dialog produced by running the driver program (making use of a DateConverters class in which all six conversion methods are complete and correct). User input is in boldface. You'll notice that, more often than not, when a conversion method is applied to a date not in the format it expects, it ends up throwing an exception.

You might also notice that, even though the second date entered by the user is a syntactically valid dd-mm-yyyy date, it is semantically invalid, as there is no such thing as the 13th month. The method for converting dd-mm-yyyy dates is not responsible for recognizing semantic invalidity, nor is any other of the conversion methods. Determining semantic validity is outside the scope of this assignment.


Additional/Optional (Extra Credit)

Two of the six non-canonical calendar date forms include spaces. To impress your instructor, make the methods that convert those forms able to handle dates in which leading, trailing, and "extra" internal spaces occur. For example, "  October   12 ,  1988 "

Submitting Your Source Code

To submit your program, log into the Student File Submission System (see link near top of course web page) and then click on the link to the "prog4_dir" folder. In the text box, enter a title (e.g., "date conversion"), then click on one of the "Browse" buttons, after which you can browse within your computer's secondary storage to find the file that you want to submit/upload, which is the file containing your DateConverters Java source code. Its name must be DateConverters.java. (Do not submit the associated .class file.)

After you click on the "SUBMIT FORM" button, you should get a message confirming that your file was submitted/uploaded. You can then click on the large "Continue" link at the top right of the page, which should take you back to the page from which you made the submission. Above the "Form to Submit Message ..." there should be a table that lists any files that you have submitted to the prog4_dir folder. To double-check that you submitted the intended file, click on the corresponding link to download the file into some application (e.g., jGrasp, WordPad) that allows you to examine it to verify that it is the correct file.

Note that you can submit more than one time to the same folder. Hence, if, after submitting, you improve your program (e.g., by fixing logic errors or by enhancing your comments), you should submit the newer version. Do not use a new file name every time you submit. Rather, use the same name each time. Within your submission folder, any previously submitted file having the same name will be renamed automatically (and still be accessible to both you and your instructor). Generally speaking, however, your instructor will probably examine only your most recent submission, unless you make a request to the contrary.

Make sure to include comments in your program identifying yourself, indicating that it is a solution to CMPS 134's Prog. Assg. #4, acknowledging any persons who aided you in developing your solution, and pointing out any defects of which you are aware.