本文整理匯總了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;
}