当前位置: 首页>>代码示例>>Java>>正文


Java DateTime.getValue方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:andyCano,项目名称:TaskApp,代码行数:15,代码来源:GtasksApiUtilities.java

示例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();
}
 
开发者ID:andyCano,项目名称:TaskApp,代码行数:29,代码来源:GtasksTaskContainer.java

示例3: gtasksCompletedTimeToUnixTime

import com.google.api.client.util.DateTime; //导入方法依赖的package包/类
public static long gtasksCompletedTimeToUnixTime(DateTime gtasksCompletedTime) {
    if (gtasksCompletedTime == null) {
        return 0;
    }
    return gtasksCompletedTime.getValue();
}
 
开发者ID:andyCano,项目名称:TaskApp,代码行数:7,代码来源:GtasksApiUtilities.java

示例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;
	}
 
开发者ID:fjakop,项目名称:ngcalsync,代码行数:44,代码来源:GoogleCalendarDAO.java

示例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;
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:62,代码来源:GCalEventDownloader.java


注:本文中的com.google.api.client.util.DateTime.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。