本文整理汇总了Java中java.time.OffsetDateTime.toLocalDateTime方法的典型用法代码示例。如果您正苦于以下问题:Java OffsetDateTime.toLocalDateTime方法的具体用法?Java OffsetDateTime.toLocalDateTime怎么用?Java OffsetDateTime.toLocalDateTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.OffsetDateTime
的用法示例。
在下文中一共展示了OffsetDateTime.toLocalDateTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convert
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Override
public LocalDateTime convert(OffsetDateTime source) {
return source.toLocalDateTime();
}
示例2: convert
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Override
public GoogleEntry convert(Event source) {
Objects.requireNonNull(source.getStart());
Objects.requireNonNull(source.getEnd());
GoogleEntry entry = new GoogleEntry();
/*
* TimeZone : Although Google allows different Start/End TimeZone, we
* always assume that start/end are in the TimeZone of the startDate.
*/
ZoneId zoneId;
String stTimeZone = source.getStart().getTimeZone();
if (stTimeZone == null) {
zoneId = ZoneId.systemDefault();
} else {
zoneId = TimeZone.getTimeZone(stTimeZone).toZoneId();
}
// Start Time
DateTime stdt = source.getStart().getDate();
if (stdt == null) {
stdt = source.getStart().getDateTime();
}
ZoneOffset stOffset = ZoneOffset.ofTotalSeconds(stdt.getTimeZoneShift() * 60);
OffsetDateTime offsetSt = Instant.ofEpochMilli(stdt.getValue()).atOffset(stOffset);
// End Time
DateTime etdt = source.getEnd().getDate();
if (etdt == null) {
etdt = source.getEnd().getDateTime();
}
ZoneOffset etoffset = ZoneOffset.ofTotalSeconds(etdt.getTimeZoneShift() * 60);
OffsetDateTime offsetEt = Instant.ofEpochMilli(etdt.getValue()).atOffset(etoffset);
LocalDateTime startDateTime = offsetSt.toLocalDateTime();
if (stdt.isDateOnly() || offsetEt.toLocalTime().equals(LocalTime.MIDNIGHT)) {
offsetEt = offsetEt.minusDays(1);
entry.setInterval(new Interval(startDateTime.toLocalDate(), startDateTime.toLocalTime(), offsetEt.toLocalDate(), LocalTime.MAX));
} else {
entry.setInterval(new Interval(startDateTime, offsetEt.toLocalDateTime()));
}
if (source.getRecurrence() != null && !source.getRecurrence().isEmpty()) {
entry.setRecurrenceRule(source.getRecurrence().get(0));
}
if (source.getAttendees() != null) {
entry.getAttendees().setAll(source.getAttendees());
}
if (source.getReminders() != null) {
Event.Reminders reminders = source.getReminders();
if (Boolean.TRUE.equals(reminders.getUseDefault())) {
entry.setUseDefaultReminder(true);
} else if (reminders.getOverrides() != null) {
List<GoogleEntryReminder> entryReminders = new ArrayList<>();
for (EventReminder reminder : reminders.getOverrides()) {
entryReminders.add(new GoogleEntryReminder(reminder));
}
entry.getReminders().setAll(entryReminders);
}
}
entry.setId(source.getId());
entry.setTitle(source.getSummary());
entry.setLocation(source.getLocation());
entry.setZoneId(zoneId);
entry.setFullDay(stdt.isDateOnly());
entry.setAttendeesCanModify(source.isGuestsCanModify());
entry.setAttendeesCanInviteOthers(source.isGuestsCanInviteOthers());
entry.setAttendeesCanSeeOthers(source.isGuestsCanSeeOtherGuests());
entry.setStatus(GoogleEntry.Status.fromName(source.getStatus()));
entry.setUserObject(source);
return entry;
}