Example usage for java.time OffsetDateTime minus

List of usage examples for java.time OffsetDateTime minus

Introduction

In this page you can find the example usage for java.time OffsetDateTime minus.

Prototype

@Override
public OffsetDateTime minus(long amountToSubtract, TemporalUnit unit) 

Source Link

Document

Returns a copy of this date-time with the specified amount subtracted.

Usage

From source file:Main.java

public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.now();
    OffsetDateTime d = o.minus(20, ChronoUnit.HOURS);
    System.out.println(d);//from ww  w . j ava2s .  c  om
}

From source file:org.silverpeas.core.calendar.notification.CalendarContributionReminderUserNotificationTest.java

private void triggerDateTime(DurationReminder reminder) throws IllegalAccessException {
    Optional<Contribution> contribution = contributionManager.getById(reminder.getContributionId());
    if (contribution.isPresent()) {
        final CalendarEvent event = (CalendarEvent) contribution.get();
        final OffsetDateTime occStartDate;
        if (event.isOnAllDay()) {
            occStartDate = ((LocalDate) currentPeriod.getStartDate())
                    .atStartOfDay(event.getCalendar().getZoneId()).toOffsetDateTime();
        } else {/*from ww w. j a  va 2  s.  co m*/
            occStartDate = (OffsetDateTime) currentPeriod.getStartDate();
        }
        final OffsetDateTime finalDateTime = occStartDate
                .minus(reminder.getDuration(), reminder.getTimeUnit().toChronoUnit()).toZonedDateTime()
                .withZoneSameInstant(ZoneId.systemDefault()).toOffsetDateTime();
        FieldUtils.writeField(reminder, "triggerDateTime", finalDateTime, true);
    }
}