2017-02-26 47 views
0
 //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 

我有“timeStampCloud”和“timestampToDB”,但如何竞选两个时间戳?如果设备时区改变了,它将会发生什么。请帮忙!! :)谷歌最新的如何转换云API和当地时间之间的Google API DateTime时间戳

+1

将当地时间转换为谷歌时区。和使用比较方法你比较两个时间.. –

回答

0
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())) 

获得时差.. 根据这一时间转换,如上面的例子你的约会到谷歌时区..。 现在你比较两个日期..