DateTime field is adjusting the time based upon the GMT offset.

DateTime field is adjusting the time based upon the GMT offset.

book

Article ID: KB0085257

calendar_today

Updated On:

Products Versions
TIBCO ActiveSpaces -
Not Applicable -

Description

Description:
Whenever we try to put a DateTime value into ActiveSpaces where the timezone is set, we are noticing that the timezone value is dropped and the date/time is adjusted to GMT. For example, if we put the dateTime with the value "2006-05-04T18:13:51-07:00", the value that we see in AS is "2006-05-05T01:13:51".  The trouble is that when we perform a get on the data, we no longer have the original timezone offset to convert the data back.

Issue/Introduction

DateTime field is adjusting the time based upon the GMT offset.

Resolution

The DateTime field value is normalized to GMT time from any API, when read it is given as GMT timezone. If the same timezone is always used, you can convert the date-time object into the desired timezone after a read is performed. 

The following is an example of how to convert a timezone into a desired timezone.

    DateTime datetime = result.getDateTime("time");
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz");

    sdf.setTimeZone(TimeZone.getTimeZone("PDT"));
    System.out.println(sdf.format(datetime.getTime().getTime()));

    sdf.setTimeZone(TimeZone.getTimeZone("EST"));
    System.out.println(sdf.format(datetime.getTime().getTime()));


For more on the date format, see:

http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

Example output from ASOperations example.

    Main: [b/c/r/s/br/p/pm/cp/g/t/l/u/h/q]: p
    Put: Enter the key (integer): 1

    Put: Enter the value (string): data
    Put Success
    Old value: null
    Main: [b/c/r/s/br/p/pm/cp/g/t/l/u/h/q]: g
    Get: Enter the key (integer):1
    Value: {Tuple {value=data, time=2014-06-06T19:54:56.455GMT, key=1} }
    2014-06-06T19:54:56.455GMT
    2014-06-06T14:54:56.455EST


Additional Information