Java Code Examples for java.time.OffsetDateTime#isAfter()

The following examples show how to use java.time.OffsetDateTime#isAfter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpdateChecker.java    From blackduck-alert with Apache License 2.0 6 votes vote down vote up
/**
 * The Date Alert has in the About will always be slightly before the Docker Hub date. So if the two are within 1 hour of each other, then we will consider them the same.
 */
private int compareDateStrings(String first, String second) {
    try {
        OffsetDateTime firstDate = parseDate(first, DOCKER_DATE_FORMAT);
        OffsetDateTime secondDate = parseDate(second, DOCKER_DATE_FORMAT);

        OffsetDateTime hourEarlier = firstDate.minusHours(1);
        OffsetDateTime hourLater = firstDate.plusHours(1);

        boolean secondIsWithinAnHourOfFirst = hourEarlier.isBefore(secondDate) && hourLater.isAfter(secondDate);

        if (secondIsWithinAnHourOfFirst) {
            return 0;
        }
        if (firstDate.isAfter(secondDate)) {
            return -1;
        } else if (firstDate.isBefore(secondDate)) {
            return 1;
        }
    } catch (ParseException e) {
        logger.debug("Could not parse the date strings with the format {}.", DOCKER_DATE_FORMAT);
        logger.debug(e.getMessage(), e);
    }
    return 0;
}
 
Example 2
Source File: FacebookLoginData.java    From OAuth-2.0-Cookbook with MIT License 5 votes vote down vote up
public boolean hasExpired() {
    OffsetDateTime expirationDateTime = OffsetDateTime.ofInstant(
            Instant.ofEpochSecond(expirationTime), ZoneId.systemDefault());

    OffsetDateTime now = OffsetDateTime.now(ZoneId.systemDefault());

    return now.isAfter(expirationDateTime);
}
 
Example 3
Source File: OpenIDAuthentication.java    From OAuth-2.0-Cookbook with MIT License 5 votes vote down vote up
public boolean hasExpired() {
    OffsetDateTime expirationDateTime = OffsetDateTime.ofInstant(
            Instant.ofEpochSecond(expirationTime), ZoneId.systemDefault());

    OffsetDateTime now = OffsetDateTime.now(ZoneId.systemDefault());

    return now.isAfter(expirationDateTime);
}
 
Example 4
Source File: OpenIDAuthentication.java    From OAuth-2.0-Cookbook with MIT License 5 votes vote down vote up
public boolean hasExpired() {
    OffsetDateTime expirationDateTime = OffsetDateTime.ofInstant(
            Instant.ofEpochSecond(expirationTime), ZoneId.systemDefault());

    OffsetDateTime now = OffsetDateTime.now(ZoneId.systemDefault());

    return now.isAfter(expirationDateTime);
}
 
Example 5
Source File: TCKOffsetDateTime.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_isAfter_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isAfter(null);
}
 
Example 6
Source File: PDTHelper.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static OffsetDateTime getMax (@Nonnull final OffsetDateTime aDateTime1,
                                     @Nonnull final OffsetDateTime aDateTime2)
{
  return aDateTime1.isAfter (aDateTime2) ? aDateTime1 : aDateTime2;
}
 
Example 7
Source File: TCKOffsetDateTime.java    From j2objc with Apache License 2.0 4 votes vote down vote up
@Test(expected=NullPointerException.class)
public void test_isAfter_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isAfter(null);
}
 
Example 8
Source File: TCKOffsetDateTime.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_isAfter_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isAfter(null);
}
 
Example 9
Source File: TCKOffsetDateTime.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_isAfter_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isAfter(null);
}
 
Example 10
Source File: TCKOffsetDateTime.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_isAfter_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isAfter(null);
}
 
Example 11
Source File: TCKOffsetDateTime.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_isAfter_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isAfter(null);
}
 
Example 12
Source File: TCKOffsetDateTime.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_isAfter_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isAfter(null);
}
 
Example 13
Source File: TCKOffsetDateTime.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_isAfter_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isAfter(null);
}
 
Example 14
Source File: TCKOffsetDateTime.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_isAfter_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isAfter(null);
}
 
Example 15
Source File: TCKOffsetDateTime.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_isAfter_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isAfter(null);
}
 
Example 16
Source File: TCKOffsetDateTime.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_isAfter_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isAfter(null);
}
 
Example 17
Source File: TCKOffsetDateTime.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_isAfter_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isAfter(null);
}
 
Example 18
Source File: TCKOffsetDateTime.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_isAfter_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isAfter(null);
}
 
Example 19
Source File: TCKOffsetDateTime.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void test_isAfter_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isAfter(null);
}