Index: test/java/javax/jdo/identity/ObjectIdentityTest.java =================================================================== --- test/java/javax/jdo/identity/ObjectIdentityTest.java (revision 582405) +++ test/java/javax/jdo/identity/ObjectIdentityTest.java (working copy) @@ -237,6 +237,14 @@ "java.util.Date:" + rightNow); } + public void testStringNullDateConstructor() { + // this test uses the standard date-time format + // "M/d/yy h:mm a" + helper.registerDateFormat(DateFormat.getInstance()); + Object c1 = new ObjectIdentity(Object.class, + "java.util.Date:" + "10/9/2007 4:26 PM"); + } + public void testBadStringDateConstructor() { try { ObjectIdentity c1 = new ObjectIdentity(Object.class, Index: src/java/javax/jdo/spi/JDOImplHelper.java =================================================================== --- src/java/javax/jdo/spi/JDOImplHelper.java (revision 582408) +++ src/java/javax/jdo/spi/JDOImplHelper.java (working copy) @@ -26,6 +26,9 @@ import java.lang.reflect.Constructor; +import java.security.AccessController; +import java.security.PrivilegedAction; + import java.text.DateFormat; import java.text.ParsePosition; import java.text.SimpleDateFormat; @@ -120,7 +123,7 @@ /** Register the default DateFormat instance. */ static { - jdoImplHelper.registerDateFormat(DateFormat.getDateTimeInstance()); + jdoImplHelper.registerDateFormat(getDateTimeInstance()); } /** Creates new JDOImplHelper */ @@ -794,10 +797,39 @@ } /** + * Get the DateFormat instance for the default locale from the VM. + * This requires the following privileges for JDOImplHelper in the + * security permissions file: + * permission java.util.PropertyPermission "user.country", "read"; + * permission java.util.PropertyPermission "user.timezone", "read,write"; + * permission java.util.PropertyPermission "java.home", "read"; + * If these permissions are not present, or there is some other + * problem getting the default date format, a simple formatter is returned. + * @since 2.1 + * @return the default date-time formatter + */ + static DateFormat getDateTimeInstance() { + DateFormat result = null; + try { + result = (DateFormat) AccessController.doPrivileged ( + new PrivilegedAction () { + public Object run () { + return DateFormat.getDateTimeInstance(); + } + } + ); + } catch (Exception ex) { + result = DateFormat.getInstance(); + } + return result; + } + + /** * Register a DateFormat instance for use with constructing Date * instances. The default is the default DateFormat instance. * If the new instance implements SimpleDateFormat, get its pattern * for error messages. + * @since 2.0 * @param df the DateFormat instance to use */ public synchronized void registerDateFormat(DateFormat df) {