Time, DateTime and Duration properties are supported in the MDEX Engine. You define them in Developer Studio.
Note
The DateTime property is available in Developer Studio by default and does not require additional configuration. However, Time and Duration property types are only enabled if you configure Developer Studio for their use. For details, see the section "Configuring Developer Studio for the use of Time and Duration Property Types" in the Oracle Commerce Developer Studio Installation Guide.
The Property editor provides three temporal property types:
In the example below, the Time property has been declared to be of the Time type, the TimeStamp property has been declared to be of the DateTime type, and the DeliveryDelay property has been declared to be of the Duration type:
Properties of type Time, DateTime, and Duration can be used for:
For information about temporal properties in Analytics queries, and time-specific operators in the Analytics API, see the MDEX Engine Analytics Guide.
Time properties represent the time of day to a resolution of milliseconds.
A string value in a Time
property, both on input to the MDEX Engine and when accessed through the
Analytics API, should contain an integer representing the number of
milliseconds since the start of day,
midnight/12:00:00AM
. Time properties are stored as
32-bit integers.
For example,
1:00PM
or
13:00
would be represented as
46800000
because:
13 hours * 60 minutes / hour * 60 seconds / minute * 1000 milliseconds / second = 46800000
DateTime properties represent the date and time to a resolution of milliseconds.
A string value in a DateTime property should contain an integer representing the number of milliseconds since the epoch (January 1, 1970). Additionally, values must be in Coordinated Universal Time (UTC) and account for the number of milliseconds since the epoch, in conformance with POSIX standards. DateTime values are stored as 64-bit integers.
For example,
August 26, 2004 1:00PM
would be represented as
1093525200000
because:
12656 days * 24 hours / day * 60 minutes / hour * 60 seconds / minute * 1000 milliseconds / second + 46800000 milliseconds (13 hrs) = 1093525200000
Duration properties represent lengths of time with a resolution of milliseconds.
A string value in a Duration property should contain an integer number of milliseconds. Duration values are stored as 64-bit integers.
For example,
100 days
would be represented as
8640000000
because:
100days * 24 hours / day * 60 minutes / hour * 60 seconds / minute * 1000 milliseconds / second = 8640000000
Like all Oracle Commerce property types (Alpha, Floating Point, Integer, and so on), time and date values are handled during the data ingest process and in UI application code as strings, but are stored and manipulated as typed data in the Oracle Commerce MDEX Engine.
For non-Alpha property types, this raises the question of data manipulation in the Forge pipeline and appropriate presentation of typed data in the UI.
At data ingest time, inbound temporal data is unlikely to conform to the
representations required by Oracle Commerce temporal property types. But time and date
classes for performing needed conversions are readily available in the standard
Java library (see
java.text.DateFormat
). These should be used (in the
context of a JavaManipulator Forge component) to convert inbound data in the
data ingest pipeline.
For example, the following code performs simple input conversion on source date strings of the form "August 26, 2009" to Oracle Commerce DateTime property format:
String sourceDate = … // String of form "August 26, 2009" DateFormat dateFmt = DateFormat.getDateInstance(DateFormat.LONG); Date date = dateFmt.parse(sourceDate); Long dateLong = new Long(date.getTime()); String dateDateTimeValue = dateLong.toString();
Similarly, in most cases the integer representation of times and dates
supported by the Oracle Commerce MDEX Engine is not suitable for application display.
Again, the application should make use of standard library components (such as
java.util.Date
and
java.util.GregorianCalendar
) to convert Oracle Commerce dates
for presentation.
For example, the following code performs a simple conversion of a DateTime value to a pretty-printable string:
String dateStr = … // Initialized to an Endeca DateTime value long dateLong = Long.parseLong(dateStr); Date date = new Date(dateLong); String dateRenderString = date.toString();