Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/213.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在云和本地时间之间转换GoogleAPI日期时间戳_Android_Google Tasks Api - Fatal编程技术网

Android 如何在云和本地时间之间转换GoogleAPI日期时间戳

Android 如何在云和本地时间之间转换GoogleAPI日期时间戳,android,google-tasks-api,Android,Google Tasks Api,我有“timeStampCloud”和“timestampToDB”,但是这两个时间戳是如何定义的呢? 如果设备时区发生变化,将会发生什么情况。请帮忙!!:) 获取谷歌日期的时区。。 根据该时间将日期转换为谷歌时区。。如上面的例子所示。 现在比较两个日期。将本地时间转换为谷歌时区。使用比较法,你可以比较两种时间。。 //Push Insert a Task: Calendar calendar = Calendar.getInstance(); long timestam

我有“timeStampCloud”和“timestampToDB”,但是这两个时间戳是如何定义的呢? 如果设备时区发生变化,将会发生什么情况。请帮忙!!:)

获取谷歌日期的时区。。 根据该时间将日期转换为谷歌时区。。如上面的例子所示。
现在比较两个日期。

将本地时间转换为谷歌时区。使用比较法,你可以比较两种时间。。
        //Push Insert a Task:
  Calendar calendar = Calendar.getInstance();
  long timestampToDB = calendar.getTimeInMillis();
    com.google.api.services.tasks.model.Task newTask = new com.google.api.services.tasks.model.Task();
    newTask.setTitle("New Task");
    DateTime timeStampLocale = new DateTime(calendar.getTime(), calendar.getTimeZone());
    newTask.setUpdated(timeStampLocale);

    //Pull the Task:
    com.google.api.services.tasks.model.Task theTask = Tasks.geTaskById(String taskId);
    DateTime timeStampCloud = theTask.getUpdated();

    //Compare Timestamp:
    //How to compare the two timestamp, in order to see which timestamp one is latest
   DateFormat formatter= new SimpleDateFormat("MM/dd/yyyy HH:mm:ss Z");
 formatter.setTimeZone(TimeZone.getTimeZone("Europe/London"));
 System.out.println(formatter.format(date));
 formatter.setTimeZone(TimeZone.getTimeZone("Europe/Athens")); System.out.println(formatter.format(instance2.getTime()))