|
Working Around Bug 3958528 Where Date Format Truncates Time
Bug 3958528 reports a problem where the time portion of an oracle.jbo.domain.Date-valued attribute is truncated when it get formatted using the default date formatter.This note describes a workaround until we're able to include the fix in a maintenance release.
Observing the Problem
To observe the problem:
- Make sure some employee in your SCOTT account's EMP table has a time portion in its HIREDATE column value. For example, you might go into SQL*Plus and issue the command:
UPDATE emp SET hiredate = SYSDATE WHERE empno = 7839; COMMIT;
- In JDeveloper, use the Business Components from Tables wizard to create a default entity object, view object, and appliation module for the SCOTT.EMP table.
- Visit the Entity Object editor for the Emp entity object, and expand the Attributes section to see the Hiredate attribute
- Click the Control Hints tab
- Select Simple Date for the Format Type
- Enter a format mask of MM/dd/yyyy HH:mm:ss
- Click (OK)
- Click on the application module and pick Test... from the right mouse menu
You'll see in the tester that the Hiredate attribute value shows a formatted time of 00:00:00 incorrectly.
Working Around the Problem
To workaround the problem, we'll create a custom date formatter which duplicates what the oracle.jbo.format.DefaultDateFormatter does, but which doesn't run into the problem above.
To workaround the problem:
- Create a new Java class named MyDefaultDateFormatter in any convenient package. For example, let's assume you call it, test.common.MyDefaultDateFormatter.
- Press [Ctrl]-[Minus] to "Goto Source" and type in the class name DefaultDateFormatter (the oracle.jbo.format package should be defaulted for you), and show the source code for it.
NOTE: The source code for this class in included with JDeveloper in the ./BC4J/src/bc4jhtmlsrc.zip archive.
- Press [Ctrl]-A to copy the entire source of this file.
- In the editor buffer for MyDefaultDateFormatter, press [Ctrl]-A to select the entire file, then press [Ctrl]-V to paste the contents of DefaultDateFormatter in its place.
- Change the package name of this class back to test.common again.
- Search for DefaultDateFormatter and replace it to be named MyDefaultDateFormatter in the class name and the constructor method name.
- Add the line:
import oracle.jbo.format.*; to the import section at the top of the file.
- Find the two places in the file where the call to the dateValue() method appears, and replace both of them with a call to timestampValue() instead.
- Compile the class.
- Visit the Emp entity object in the Entity Object editor again, and visit the panel for the Hiredate attribute.
- This time, click on the Attribute Properties tab
- In the Name field, enter the string (exactly as shown) value of FMT_FORMATTER
- In the Value field, enter the fully-qualified name of the custom formatter object test.common.MyDefaultDateFormatter
- Click (OK).
Now try repeating the test using the Business Components Tester tool, and you'll see that by using the custom date formatter object that fixed the calls to dateValue() to be calls to timestampValue() instead, you now correctly see the time portion of the date for the KING employee with EMPNO = 7839.
NOTE: If you deploy your ADF Business Components-based application in a physical three-tier architecture, the custom formatter classes need to be available both in the middle-tier environment and the remote client environment, so you should double-check that it gets included in both deployment profiles so it ends up in both MiddleTier and Common JAR files.
|