本文整理汇总了Java中com.google.api.client.util.DateTime.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java DateTime.getValue方法的具体用法?Java DateTime.getValue怎么用?Java DateTime.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.client.util.DateTime
的用法示例。
在下文中一共展示了DateTime.getValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: gtasksDueTimeToUnixTime
import com.google.api.client.util.DateTime; //导入方法依赖的package包/类
public static long gtasksDueTimeToUnixTime(DateTime gtasksDueTime) {
if (gtasksDueTime == null) {
return 0;
}
try {
long utcTime = gtasksDueTime.getValue(); //DateTime.parseRfc3339(gtasksDueTime).value;
Date date = new Date(utcTime);
Date returnDate = new Date(date.getTime() + date.getTimezoneOffset() * 60000);
return returnDate.getTime();
} catch (NumberFormatException e) {
Timber.e(e, e.getMessage());
return 0;
}
}
示例2: GtasksTaskContainer
import com.google.api.client.util.DateTime; //导入方法依赖的package包/类
public GtasksTaskContainer(com.google.api.services.tasks.model.Task remoteTask, String listId, Metadata metadata) {
this.task = new Task();
this.metadata = new ArrayList<>();
this.gtaskMetadata = metadata;
task.setTitle(remoteTask.getTitle());
task.setCreationDate(DateUtilities.now());
task.setCompletionDate(GtasksApiUtilities.gtasksCompletedTimeToUnixTime(remoteTask.getCompleted()));
if (remoteTask.getDeleted() == null || !remoteTask.getDeleted()) {
task.setDeletionDate(0L);
} else {
task.setDeletionDate(DateUtilities.now());
}
if (remoteTask.getHidden() != null && remoteTask.getHidden()) {
task.setDeletionDate(DateUtilities.now());
}
long dueDate = GtasksApiUtilities.gtasksDueTimeToUnixTime(remoteTask.getDue());
long createdDate = Task.createDueDate(Task.URGENCY_SPECIFIC_DAY, dueDate);
task.setDueDate(createdDate);
task.setNotes(remoteTask.getNotes());
gtaskMetadata.setValue(GtasksMetadata.ID, remoteTask.getId());
gtaskMetadata.setValue(GtasksMetadata.LIST_ID, listId);
DateTime updated = remoteTask.getUpdated();
updateTime = updated == null ? 0 : updated.getValue();
}
示例3: gtasksCompletedTimeToUnixTime
import com.google.api.client.util.DateTime; //导入方法依赖的package包/类
public static long gtasksCompletedTimeToUnixTime(DateTime gtasksCompletedTime) {
if (gtasksCompletedTime == null) {
return 0;
}
return gtasksCompletedTime.getValue();
}
示例4: convGoogleEvent
import com.google.api.client.util.DateTime; //导入方法依赖的package包/类
private CalendarEvent convGoogleEvent(final Event googleEvent) {
final CalendarEvent myEvent = new CalendarEvent();
myEvent.setTitle(googleEvent.getSummary());
myEvent.setContent(googleEvent.getDescription());
myEvent.setId(googleEvent.getId());
myEvent.setLocation(googleEvent.getLocation());
final Calendar u = Calendar.getInstance();
u.setTimeInMillis(googleEvent.getUpdated().getValue());
myEvent.setLastUpdated(u);
// Visibility visibility = entry.getVisibility();
DateTime sdt = null;
DateTime edt = null;
if (googleEvent.getStart().getDateTime() == null) {
// all day event - no DateTime, only Date present
myEvent.setEventType(EventType.ALL_DAY_EVENT);
sdt = googleEvent.getStart().getDate();
edt = googleEvent.getEnd().getDate();
} else {
// "timed" event - DateTime present
sdt = googleEvent.getStart().getDateTime();
edt = googleEvent.getEnd().getDateTime();
if (sdt.getValue() == edt.getValue()) {
myEvent.setEventType(EventType.REMINDER);
} else {
myEvent.setEventType(EventType.NORMAL_EVENT);
}
}
final Calendar sdtCalendar = Calendar.getInstance();
sdtCalendar.setTimeInMillis(sdt.getValue());
myEvent.setStartDateTime(sdtCalendar);
final Calendar edtCalendar = Calendar.getInstance();
edtCalendar.setTimeInMillis(edt.getValue());
myEvent.setEndDateTime(edtCalendar);
return myEvent;
}
示例5: downloadEventFeed
import com.google.api.client.util.DateTime; //导入方法依赖的package包/类
/**
* Connects to Google-Calendar Service and returns the specified Events
*
* @return the corresponding Events or <code>null</code> if an error
* occurs. <i>Note:</i> We do only return events if their startTime lies between
* <code>now</code> and <code>now + 2 * refreshInterval</code> to reduce
* the amount of events to process.
*/
private static Events downloadEventFeed() {
// TODO: teichsta: there could be more than one calendar url in openHAB.cfg
// for now we accept this limitation of downloading just one feed ...
if (StringUtils.isBlank(calendar_name)) {
logger.warn("Login aborted no calendar name defined");
return null;
}
// authorization
CalendarListEntry calendarID = GCalGoogleOAuth.getCalendarId(calendar_name);
if (calendarID == null) {
return null;
}
DateTime start = new DateTime(new Date(), TimeZone.getTimeZone(calendarID.getTimeZone()));
DateTime end = new DateTime(new Date(start.getValue() + (2 * refreshInterval)),
TimeZone.getTimeZone(calendarID.getTimeZone()));
logger.debug("Downloading calendar feed for time interval: {} to {} ", start, end);
Events feed = null;
try {
Credential credential = GCalGoogleOAuth.getCredential(false);
// set up global Calendar instance
Calendar client = new Calendar.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
.setApplicationName("openHAB").build();
Calendar.Events.List l = client.events().list(calendarID.getId()).setSingleEvents(true).setTimeMin(start)
.setTimeMax(end);
// add the fulltext filter if it has been configured
if (StringUtils.isNotBlank(filter)) {
l = l.setQ(filter);
}
feed = l.execute();
} catch (IOException e1) {
logger.error("Event fetch failed: {}", e1.getMessage());
}
try {
if (feed != null) {
checkIfFullCalendarFeed(feed.getItems());
}
return feed;
} catch (Exception e) {
logger.error("downloading CalendarEventFeed throws exception: {}", e.getMessage());
}
return null;
}