如何在云时间和本地时间之间转换 Google API DateTime 时间戳
How to convert Google API DateTime timestamp between Cloud and local time
//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",但是如何比较这两个时间戳?
如果设备时区发生变化,将会发生什么。请帮忙!! :)
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()))
获取 google 日期的时区..
根据那个时间将您的日期转换为 google 时区.. 如上例所示。
现在你比较两个日期..
//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",但是如何比较这两个时间戳? 如果设备时区发生变化,将会发生什么。请帮忙!! :)
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()))
获取 google 日期的时区.. 根据那个时间将您的日期转换为 google 时区.. 如上例所示。 现在你比较两个日期..