Problem 2: Year 2000

OK, you knew there had to be a Y2K problem, so here it is.

You are given a document containing text and numerical data, which may include dates. Your task is to identify (two-digit) years and to reprint the document with these two-digit years replaced by four-digit years. You may assume that any year numbered 24 or less is in the 2000's, while any year numbered 25 or more is in the 1900's (e.g. 16 represents the year 2016 and 26 represents the year 1926). (Yes, we know this rule may imply that your grandmother hasn't been born yet.)

Your program is to recognize dates in any of three formats:

```dd/mm/yy yy.mm.dd Month,dd,yy```

where dd is a two-digit day between 01 and 31, mm is a two-digit month between 01 and 12, yy is a two digit year between 00 and 99, and Month is one of: January, February, March, April, May, June, July, August, September, October, November, December. The first two formats contain no spaces, and the third format contains a single space after Month and a single space after the comma.

Dates should appear on a single line. Dates traversing two lines or dates immediately adjacent to a letter of the alphabet or a digit should not be recognized. Non-existent data such as February 30, 99 do not need to be checked for.

The first line of input to your program will contain a positive integer n, indicating the number of lines of text to follow. In each of the lines of text you are to find all dates that occur in any of the formats above, and replace the two-digit year by the appropriate four-digit year as described above.

Sample Input

```4 Before 02/03/04, but not after December 19, 99, there was a rehash of the 55.34.02 meeting. A date, like November 15, 95 cannot traverse two lines, nor can it be surrounded by alphabetics or numerics like this: 78November 01, 88, or 6801/12/03, or 02/03/04x.```

Sample Output

```Before 02/03/2004, but not after December 19, 1999, there was a rehash of the 55.34.02 meeting. A date, like November 15, 95 cannot traverse two lines, nor can it be surrounded by alphabetics or numerics like this: 78November 01, 88, or 6801/12/03, or 02/03/04x.```

Point Value: 10
Time Limit: 2.00s
Memory Limit: 16M

Problem Types: [Show]

Languages Allowed:
C++03, PAS, C, HASK, ASM, JAVA, CAML, C#, C++11

• (0/0)
Can you let me know how to fix the compiling issue? ccc99s2.java:7: error: package java.time.format does not exist
import java.time.format.DateTimeFormatter;
Thank you.

• (0/0)
That's only in the Java 8 SDK. The judge uses Java 7.

• (1/0)
The instructions indicate that there is a comma after the month for the 3rd date format, so it wouldn't detect the 2nd date in the first line of the test case.

So shouldn't the output be:

Before 02/03/2004, but not after December 19, 99,
there was a rehash of the 55.34.02 meeting. A date, like November 15,
95 cannot traverse two lines, nor can it be surrounded by alphabetics
or numerics like this: 78November 01, 88, or 6801/12/03, or 02/03/04x.

Could someone clarify the format of the dates, please?

• (1/0)
The third format could be more accurately stated as "Month dd, yy".