Java Date Translator (External Object)
**NOTE: This Functionality Has Been Deprecated.
Please use this link to see alternative features:
https://www.mrc-productivity.com/legacy/external-objects-udf/mrc-date-conversion-udfs
mrc supplies a date translator specifically for use with generated Web/Servlet applications. This Java class is named mrc.servlet.MrcDateTranslator and resides in mrcextobj.jar.
The object definition is shown below. If this object definition is not on your system, then a cumulative update from August 1, 2004 or later will install it.
Object Definition
Object Name |
MRCDATEJVA |
Object Description |
Java Date Translator |
Where Available |
0 |
Object Type |
M |
Class/exe |
mrc.servlet.MrcDateTranslator |
Method |
convert |
Classpath/path |
/mrcjava/web-inf/lib/mrcextobj.jar |
Object Parameters
Sequence Number |
Description |
Length |
10 |
Input: 6.0 numeric (*MDY6mmddyy) |
6.0 |
20 |
Input: 6.0 numeric (*DMY6ddmmyy) |
6.0 |
30 |
Input: 6.0 numeric (*YMD6yymmdd) |
6.0 |
40 |
Input: 8.0 numeric (*MDY8mmddyyyy) |
8.0 |
50 |
Input: 8.0 numeric (*DMY8ddmmyyyy) |
8.0 |
60 |
Input: 8.0 numeric (*YMD8yyyymmdd) |
8.0 |
70 |
Input: 5.0 numeric (*YD5yyddd) |
5.0 |
80 |
Input: 7.0 numeric (*YD7yyyyddd) |
7.0 |
90 |
Input: 7.0 numeric (*CMDY7cmmddyy) |
7.0 |
100 |
Input: 7.0 numeric (*CDMY7cddmmyy) |
7.0 |
110 |
Input: 7.0 numeric (*CYMD7cyymmdd) |
7.0 |
120 |
Input: date field (*MDY mm/dd/yy) |
8 |
130 |
Input: date field (*DMYdd/mm/yy) |
8 |
140 |
Input: date field (*YMDyy/mm/dd) |
8 |
150 |
Input: date field (*JULyy/ddd) |
6 |
160 |
Input: date field (*ISOyyyy-mm-dd) |
10 |
170 |
Input: date field (*USA |
10 |
180 |
Input: date field (*EURdd.mm.yyyy) |
10 |
190 |
Input: date field (*JYNyyyynnn) |
7 |
200 |
Input: date field (*JYDyyyy/ddd) |
8 |
210 |
Input: date field (*CMDYcmm/dd/yy) |
9 |
220 |
Input: date field (*CDMYcdd/mm/yy) |
9 |
230 |
Input: date field (*CYMDcyy/mm/dd) |
9 |
240 |
Output/Input: 6.0 format (*MDY6mmddyy) |
6.0 |
250 |
Output/Input: 6.0 format (*DMY6ddmmyy) |
6.0 |
260 |
Output/Input: 6.0 format (*YMD6yymmdd) |
6.0 |
270 |
Output/Input: 8.0 format (*MDY8mmddyyyy) |
8.0 |
280 |
Output/Input: 8.0 format (*DMY8ddmmyyyy) |
8.0 |
290 |
Output/Input: 8.0 format (*YMD8yyyymmdd) |
8.0 |
300 |
Output/Input: 5.0 format (*YD5yyddd) |
5.0 |
310 |
Output/Input: 7.0 format (*YD7yyyyddd) |
7.0 |
320 |
Output/Input: 7.0 format (*CMDY7cmmddyy) |
7.0 |
330 |
Output/Input: 7.0 format (*CDMY7cddmmyy) |
7.0 |
340 |
Output/Input: 7.0 format (*CYMD7cyymmdd) |
7.0 |
350 |
Output/Input: date format (*MDY mm/dd/yy) |
8 |
360 |
Output/Input: date format (*DMYdd/mm/yy) |
8 |
370 |
Output/Input: date format (*YMDyy/mm/dd) |
8 |
380 |
Output/Input: date format (*JULyy/ddd) |
6 |
390 |
Output/Input: date format (*ISOyyyy-mm-dd) |
10 |
400 |
Output/Input: date format (*USA mm/dd/yyyy) |
10 |
410 |
Output/Input: date format (*EURdd.mm.yyyy) |
10 |
420 |
Output/Input: date format (*JYNyyyynnn) |
7 |
430 |
Output/Input: date format (*JYDyyyy/ddd) |
8 |
440 |
Output/Input: date format (*CMDYcmm/dd/yy) |
9 |
450 |
Output/Input: date format (*CDMYcdd/mm/yy) |
9 |
460 |
Output/Input: date format (*CYMDcyy/mm/dd) |
9 |
470 |
Output DAY OF YEAR(*DY 1-366) |
3.0 |
480 |
Output DAY OF MONTH(*DM 1-31) |
2.0 |
490 |
Output DAY OF WEEK (*DW 1-7) |
1.0 |
500 |
Output Day of Week (*DWA Sun-Sat) |
3 |
510 |
Output Day of Week (*DWF Sunday-Saturday) |
10 |
520 |
Output MONTH OF YEAR (*MY 1-12) |
2.0 |
530 |
Output Month of Year (*MYA Jan-Dec) |
3 |
540 |
Output Month of Year (*MYF January-December) |
10 |
550 |
Output YEAR in YY (*YY 00-99) |
2.0 |
560 |
Output YEAR in YYYY (*YYYY 0001-9999) |
4.0 |
570 |
Output: Different DAYS(*DAY) |
5.0 |
580 |
Output: Different WEEKS (*WEEK) |
5.1 |
590 |
Output: Different MONTHS (*MONTH) |
5.2 |
600 |
Output: Different YEARS (*YEAR) |
5.3 |
610 |
Input: Add/Subtract Day On Input Date (*DAY) |
4.0 |
620 |
Input: Add/Subtract Week On Input Date (*WEEK) |
4.0 |
630 |
Input: Add/Subtract Month On Input Date (*MONTH) |
4.0 |
640 |
Input: Add/Subtract Year On Input Date (*YEAR) |
4.0 |
Functions
Convert Date1 to Different Format Date2
· Input Date1 ( Seq 10-230)
· Output Date2 ( Seq 240-460)
Return attributes (Day/Month/Week/Year) of Date1
· Input Date1 Seq 10-230,
· Output Value Seq 470-560
Calculate difference between Date1 and Date2
· Input Date1 ( Seq 10-230) and Date2 ( Seq 240-460)
· Output value ( Seq 570-600)
Add/ Substract Field1 (Days/Weeks/Months/Year) Value to Date1
· Input Date1 ( Seq 10-230)
· Input Field1 ( Seq 610-640)
· Output Date ( Seq 240-460)
Return Server Date/Day/Week/Month/Year
· Only map field for Output ( Seq 240-560)
Examples of Converting Numeric Date Fields
Example 1: Simple Reporting Date Conversion
The database field is YYMMDD, but the user wants MMDDYY to display in the application.
We need to convert the true database field from YYMMDD to display it on the screen as MMDDYY. Create a calculated field to hold the converted value and call the object once at external object template location *READRECRD, *CALCOBJ, or call it directly from the calculation.
Parameter Sequence # |
Description |
Map to Field |
3 |
Input: 6.0 numeric (*YMD6yymmdd) |
DB field |
24 |
Output/Input: 6.0 format (*MDY6mmddyy) |
Calc field |
Display the calculated field and non-display the database field.
Example 2: Maintain Field With Date Conversion
The database field is YYMMDD, but the user wants MMDDYY to display in the application.
If the maintenance application will update the numeric date database field, we need to perform two conversions. First, we need to convert the true database field from YYMMDD to display it on the screen in format MMDDYY. Then, when the user submits the screen to update a record, we will convert it again from screen format MMDDYY before we update the record in the database with format YYMMDD. Therefore we will call the same object twice. If the maintainer application will only add records, then only the second conversion is necessary since the value is not retrieved from the database for the purpose of displaying the current value. No calculated field is needed in either case.
Call the object at external object template location *READRECRD with these parameters:
Parameter Sequence # |
Description |
Map to Field |
3 |
Input: 6.0 numeric (*YMD6yymmdd) |
DB field |
24 |
Output/Input: 6.0 format (*MDY6mmddyy) |
Same DB field |
Call the object at external object template location *BEFOREACT with these parameters:
Parameter Sequence # |
Description |
Map to Field |
1 |
Input: 6.0 numeric (*MDY6mmddyy) |
DB field |
26 |
Output/Input: 6.0 format (*YMD6yymmdd) |
Same DB field |
Example 3: Advanced Search With Date Conversion
The database field is YYMMDD, but the user wants MMDDYY to display in the application.
We need to convert the value entered as MMDDYY to a match the database format of YYMMDD. No need to create a calculated field. Call the object once at external object location *STRADVSCH, mapping the database field as the input and the output.
Parameter Sequence # |
Description |
Map to Field |
1 |
Input: 6.0 numeric (*MDY6mmddyy) |
DB field |
26 |
Output/Input: 6.0 format (*YMD6mmddyy) |
Same DB field |
Note that you also might want to follow example 1 to display the true database field as MMDDYY on the screen also. Then, you would have two fields in the application. The true database field can be queried via advanced search, but the calculated field cannot. Display both fields in the application. Then paint the query header input field to the calculated field column heading and comment out the true database field column to hide the YYMMDD format.
https://www.mrc-productivity.com/techblog/?p=522