WebObjects 4: Correcting Century Issues in the WebObjects 4.0.1 Examples

Some of the examples included with WebObjects 4.0.1 use two-digit or three-digit date values. While this will not affect the average user's development or deployment of WebObjects applications, is not consistent with Apple's recommended date-handling practice. This article provides instructions on how to change these examples to use the preferred four-digit year format. In addition, WebObjects 4.0.1 users should install WebObjects 4.0.1 Patch 1, described in article 70134, which contains an updated version of the gnutar utility with enhanced date-handling capabilities.

ModelerBundle

The ModelerBundle example in the Enterprise Objects Examples on WebObjects 4.0.1 uses a two-digit year format for dates. The string is only used for display, not editing, so there is no problem with the function of the example. However, this is not preferred usage for Year 2000 compliant applications. The Apple reference number for this bug is 2414932.

Customers can edit the source for this example and rebuild it if a four-digit year format is desired. In $NEXT_ROOT/NextDeveloper/Examples/EnterpriseObjects/ModelerBundle/CustomeColumns.m, change the date format on line 67 from %y to %Y:

67c67
<         formatter = [[NSDateFormatter alloc]
initWithDateFormat:@"%m/%d/%y: %H:%M" allowNaturalLanguage:NO];
---
>         formatter = [[NSDateFormatter alloc]  
initWithDateFormat:@"%m/%d/%Y: %H:%M" allowNaturalLanguage:NO];

Rebuild the example according to the instructions in the EnterpriseObjects directory.

ElementTour

The WebObjects Java example "ElementTour" calls java.util.Date.getYear() without correcting for the fact that the value returned by this method is "years since 1900". The result is two-digit years through 1999, and three-digit years thereafter. This is not the preferred usage for Year 2000 compliant applications. The Apple reference number for this bug is 2415034

Customers who wish to correct this behavior may achieve this by making the following modifications in the example source and recompiling.

Add 1900 to the value returned by java.util.Date.getYear() in the following location:

$NEXT_ROOT/Developer/Examples/WebObjects/Java/ElementTour/ODE.java, line 13

Change:

        "today.getMonth()+1,\\"/\\",today.getDate(),\\"/\\",today.getYear());";

To:

        "today.getMonth()+1,\\"/\\",today.getDate(),\\"/\\",today.getYear() + 1900);";
Â

FDF1040EZ

The WebObjects Java example "FDF1040EZ" calls java.util.Date.getYear() without correcting for the fact that the value returned by this method is "years since 1900". The result is two-digit years through 1999, and three-digit years thereafter. This is not the preferred usage for Year 2000 compliant applications. The Apple reference number for this bug is 2415036.

Customers who wish to correct this behavior may achieve this by making the following modifications in the example source and recompiling.

In the file $NEXT_ROOT/Developer/Examples/WebObjects/Java/FDF1040EZ/TenFortyEZ.java:
Add the following to the import statements at the top of the file:
import java.text.*;
import java.util.*;

Change lines 111 and 112:

         java.util.Date d=new java.util.Date();
         return " "+d.getMonth()+"/"+d.getDate()+"/"+d.getYear();


To:

         return DateFormat.getDateInstance(DateFormat.SHORT).format(new Date());

Published Date: Feb 20, 2012