How to get correct dates from document properties?

We are having a problem exacting the correct times from the document properties:

  • CreatedTime
  • LastSavedTime
  • LastPrinted

The timestamp of these properties changes with the timezone of the machine that executes the code.

How do we know which timezone is the correct one? and when the presentation was actually created.

The following sample code illustrates the problem:

Presentation pres = new Presentation(filename);
IDocumentProperties props = pres.getDocumentProperties();
            
System.out.println("Timezone is:      " + TimeZone.getDefault().getID());
System.out.println("Created Date:     " + props.getCreatedTime().toString());
System.out.println("Created Date UTC: " + UTCstring(props.getCreatedTime()));

TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
System.out.println("Timezone is:      " + TimeZone.getDefault().getID());
System.out.println("Created Date:     " + props.getCreatedTime().toString());
System.out.println("Created Date UTC: " + UTCstring(props.getCreatedTime()));

TimeZone.setDefault(TimeZone.getTimeZone("Europe/Copenhagen"));
System.out.println("Timezone is:      " + TimeZone.getDefault().getID());
System.out.println("Created Date:     " + props.getCreatedTime().toString());
System.out.println("Created Date UTC: " + UTCstring(props.getCreatedTime()));

TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
System.out.println("Timezone is:      " + TimeZone.getDefault().getID());
System.out.println("Created Date:     " + props.getCreatedTime().toString());
System.out.println("Created Date UTC: " + UTCstring(props.getCreatedTime()));

Executing this code gives us the following output:

Using Aspose.Slides: 18.12
Timezone is:      America/New_York
Created Date:     Wed Nov 28 14:21:09 EST 2018
Created Date UTC: Wed Nov 28 19:21:09 UTC 2018
Timezone is:      UTC
Created Date:     Wed Nov 28 14:21:09 UTC 2018
Created Date UTC: Wed Nov 28 14:21:09 UTC 2018
Timezone is:      Europe/Copenhagen
Created Date:     Wed Nov 28 14:21:09 CET 2018
Created Date UTC: Wed Nov 28 13:21:09 UTC 2018
Timezone is:      Asia/Shanghai
Created Date:     Wed Nov 28 14:21:09 CST 2018
Created Date UTC: Wed Nov 28 06:21:09 UTC 2018

How do we know which of the timestamps are correct? Was the presentation created 14:21 Eastern US time or 14:21 Shanghai time on November 28?

This test was executed using Aspose Slides 18.12.

Attached is the sample code that also contains the presentation used for this example. Instructions on how to run the code is in the readme file.

AsposeSlidesDates.zip (328.0 KB)

@sbd,

I have observed the issue shared by you and have created an issue with ID SLIDESNET-40786 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.