SimpleDateTimeFormat Issue

2009-03-08T02:28:03.000Zdate seems to be an invalid date when we validates this data in WM 6.5 by the use of simpleDateTimeFormat class.Somehow the date and the time together seem to be a valid date time and hence WM throws this as a validation exception for the invalid date time format with the error message below

At this point,Iam not really sure of why its considered as an invalid date time as other date timestamp pass the date validation.

The below logic worked when we tried in EClipse.But when we tried the below code in WM 6.5., we got exception.Please help me on this.

date : 2009-03-08T02:28:03.000Z
format : yyyy-MM-dd’T’HH:mm:ss

Code :

// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String date = IDataUtil.getString( pipelineCursor, “date” );
String format = IDataUtil.getString( pipelineCursor, “format” );
pipelineCursor.destroy();
String isValidDate = “true”;

try
{
if (format == null)
throw new ServiceException(“Unable to validate date. The format is not specified.”);
if (date!= null && date.trim().length() != 0)
{
SimpleDateFormat df = new SimpleDateFormat(format);
df.setLenient(false);
Date d = df.parse(date);
}
}
catch (Exception e) {
isValidDate = “false”;
}
// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
IDataUtil.put( pipelineCursor_1, “isValidDate”, isValidDate );
pipelineCursor_1.destroy();

Instead of custom java service,why don’t you use built-in service to format it:

pub.date:dateTimeFormat and specify currentPattern or newPattern=yyyy-MM-dd’T’HH:mm:ss per your requirement?

HTH,
RMG

Hi,

Actually Date elements (month/date/year) should be validated.But in dateTimeFormat built-in service we wont be able to validate this. For instance if we give 2009-13-09 (yyyy-MM-dd).It will take as 2010-01-09.

Are you using the same JVM with Eclipse and with IS? Since SimpleDateFormat is a core Java library element, this wouldn’t be a wM IS issue but perhaps a JVM vendor implementation difference.

I suspect the time is rejected because it doesn’t exist! :eek:

Daylight saving time started in the USA on 8th March at 2am, when clocks were moved forward 1 hour, so no time between 2am and 3am officially exists. (This reminds me of the Twilight Zone episode that explored the 15 days that disappeared when the Gregorian Calendar was implemented.)

Changing the JVM timezone, or the timezone in your time string, will probably resolve this.