Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 361576

Summary: Intialization of a timestamp reference with a string literal causes an exception
Product: z_Archived Reporter: Kathy Carroll <carrollk>
Component: EDTAssignee: Huang Ji Yong <hjiyong>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: greer, hjiyong, mheitz, pfyu, svihovec
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Eunit variations none

Description Kathy Carroll CLA 2011-10-20 12:42:11 EDT
Created attachment 205662 [details]
Eunit variations

Intialization of a timestamp reference with a string literal causes an exception: 'undefined' is null or not an object

I've attached an eunit test file
Comment 1 Scott Greer CLA 2011-10-24 20:15:35 EDT
Matt, Brian,

I can make the attached testcases work by assuming the format is "yyyy-MM-dd HH:mm:ss", but I doubt that's the right answer given that the Java RT has logic that will parse out the string trying to extract as much timestamp info as it can in the absence of a specific format.    I don't believe the old RBD RT had anything like that, so I need guidance on whether we need to implement the equivalent of what the Java RT is doing.
Comment 2 Scott Greer CLA 2011-10-24 20:24:43 EDT
*** Bug 360411 has been marked as a duplicate of this bug. ***
Comment 3 Scott Greer CLA 2011-10-24 21:36:31 EDT
*** Bug 360408 has been marked as a duplicate of this bug. ***
Comment 4 Matt Heitz CLA 2011-10-25 08:57:39 EDT
Scott, it may be dangerous to go by what the Java RT is doing.  There's no guarantee that it's working properly yet.

The assignment statements in testFunctionParameterIn2 are invalid.  We must know the format of the timestamp in order to parse the string properly, so when the timestamp is declared without a format the conversion can't be performed.  This is mentioned in item C of http://wiki.eclipse.org/EDT:EGL_Language_Primitive_Type_Conversions

The assignment statements in testFunctionParameterIn3 should be performed according to the description of ETimestamp.asTimestamp(EString, EString).
/**
 * {@Operation narrow} Converts a string to a timestamp.  The string is parsed
 * by searching for the timestamp fields specified in the pattern, in order
 * from years down to fractions of seconds.  Each field from the pattern must
 * be present in the string.  Years must be represented with four digits,
 * fractions of seconds with six digits, and other fields with two digits.
 * One separator character must appear in between each field.  Any character
 * may be used as a separator, and the separators do not have to match.
 *
 * @throws TypeCastException if the string can't be parsed into a timestamp or the pattern is invalid.
 */
In other words, when you assign a string to a timestamp("yyyyMMddHHmmss"), the string must contain four year digits, and two digits for the months, days, hours, minutes, and seconds.  There must be one character between each of these fields.  The conversion must fail (throw a TypeCastException) if the string isn't in this format.
Comment 5 Scott Greer CLA 2011-10-25 10:57:08 EDT
Matt, thanks for the info -- that's what I needed to know in order to resolve this bug.

Changing priority to p1 because this is a fundamental issue that must be addressed and because this seems to be blocking a number of eunit tests (including some that aren't directly related to timestamps).
Comment 6 Huang Ji Yong CLA 2011-11-14 01:30:06 EST
Resolved indirectly
Verified by Pengfei
Comment 7 Kathy Carroll CLA 2011-11-14 11:17:00 EST
Verified with 20111114_2101 & closed.