book
Article ID: KB0091197
calendar_today
Updated On:
Description
Resolution:
Description:
==========
Using the following date function from catalog functions:
DateTime GmtTimeLocalOffset = DateTime.now();
DateTime dGmtDtTm = DateTime.createTime(DateTime.getYear(GmtTimeLocalOffset),
DateTime.getMonth(GmtTimeLocalOffset),
DateTime.getDate(GmtTimeLocalOffset),
DateTime.getHour(GmtTimeLocalOffset),
DateTime.getMinute(GmtTimeLocalOffset),
DateTime.getSecond(GmtTimeLocalOffset),"GMT");
This is appending milliseconds 2013-01-21T20:34:07.564Z though we are not passing any. This function was working in TIBCO BusinessEvents(BE) 3.0.2 and giving proper datetime, such as: '2013-01-21T20:34:07Z'
Environment:
===========
TIBCO BusinessEvents 4.0.2
Symptoms:
=========
When using Instance.serializeUsingDefaults() to serialize the concept, on 4.0.2, it serialize the DateTime with the following format with milliseconds: "2013-01-21T20:34:07.564Z" . On BE 3.0.2, it serialize the DateTime without the milliseconds, such as: '2013-01-21T20:34:07Z'.
Cause:
======
The DateTime property itself contains the milliseconds information on both 3.0.2 and 4.0.2 version:
>>4.0.2 >>>>>>>>>>>>>>>>
2013 Jan 21 15:03:02:146 GMT -8 hucheng-T430.na.tibco.com Info [main] - [user] [inference-class] calender java.util.GregorianCalendar[time=1358780581320,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2013,MONTH=0,WEEK_OF_YEAR=4,WEEK_OF_MONTH=4,DAY_OF_MONTH=21,DAY_OF_YEAR=21,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=3,HOUR_OF_DAY=15,MINUTE=3,SECOND=1,MILLISECOND=320,ZONE_OFFSET=0,DST_OFFSET=0]
<<<<<<<<<<<<<<<<<<
>>3.0.2 >>>>>>>>>>>>>>>>>
2013 Jan 21 15:16:10:707 GMT -8 testDateTime User [main] - [BusinessEvents Archive] ++++++++++++Calender::java.util.GregorianCalendar[time=1358781370339,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT+00:00",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2013,MONTH=0,WEEK_OF_YEAR=4,WEEK_OF_MONTH=4,DAY_OF_MONTH=21,DAY_OF_YEAR=21,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=3,HOUR_OF_DAY=15,MINUTE=16,SECOND=10,MILLISECOND=339,ZONE_OFFSET=0,DST_OFFSET=0]
<<<<<<<<<<<<<<<<<<<
The difference comes from the Instance.serializeUsingDefaults(). The 4.0.2 Instance.serializeUsingDefaults() function formats the DateTime to string with a format that carries the milliseconds.
Resolution:
==========
Use the DateTime.format() function to format a dateTime to string with your own format, for example:
DateTime.format(test.testFDate, "yyyy-MM-dd'T'HH:mm:ss'Z'");
This will format the DateTime as "2013-01-21T20:34:07Z"
Issue/Introduction
While using Instance.serializeUsingDefaults() for a concept, it adds milliseconds for the Datatime property.