Incorrect time zone returned from getActionInfo
eos1d3 opened this issue · 2 comments
eos1d3 commented
For both Image and Droplet actions, getCompletedAt should returns a string of 2014-11-14T16:32:24Z as per DigitalOcean API doc.
But I got from Java output is Thu Mar 31 12:53:19 HKT 2016. The date seems to be converted to my local time format with HKT, but the numbers are still in UTC. It needs to add +08:00 for HKT. The actual local time is Thu Mar 31 20:53:19 HKT 2016.
It seems HKT is added incorrectly. It should be UTC regardless of the local time zone.
The workaround is to replaced HKT with UTC in the date string.
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE MMM dd hh:mm:ss zzz yyyy");
Date myDate = simpleDateFormat.parse(apiClient.getActionInfo(actionID).getCompletedAt().toString().replace("HKT", "UTC"));
System.out.println("Reboot finished at: " + myDate);
System.out.println("Reboot finished at: " + apiClient.getActionInfo(actionID).getCompletedAt());
So the first line of output is correct for HKT.
Reboot finished at: Thu Mar 31 22:39:49 HKT 2016
Reboot finished at: Thu Mar 31 14:39:49 HKT 2016
PS: This affects getCompletedAt
for both DropletAction and ImageAction. And I believe the same problem to getStartedAt
jeevatkm commented
Done!