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

The following examples show how to use java.time.OffsetDateTime#compareTo() . 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: RoleImpl.java    From JDA with Apache License 2.0 6 votes vote down vote up
@Override
public int compareTo(@Nonnull Role r)
{
    if (this == r)
        return 0;
    if (!(r instanceof RoleImpl))
        throw new IllegalArgumentException("Cannot compare different role implementations");
    RoleImpl impl = (RoleImpl) r;

    if (this.guild.getIdLong() != impl.guild.getIdLong())
        throw new IllegalArgumentException("Cannot compare roles that aren't from the same guild!");

    if (this.getPositionRaw() != r.getPositionRaw())
        return this.getPositionRaw() - r.getPositionRaw();

    OffsetDateTime thisTime = this.getTimeCreated();
    OffsetDateTime rTime = r.getTimeCreated();

    //We compare the provided role's time to this's time instead of the reverse as one would expect due to how
    // discord deals with hierarchy. The more recent a role was created, the lower its hierarchy ranking when
    // it shares the same position as another role.
    return rTime.compareTo(thisTime);
}
 
Example 2
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_compareTo_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.compareTo(null);
}
 
Example 3
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_compareTo_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.compareTo(null);
}
 
Example 4
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_compareTo_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.compareTo(null);
}
 
Example 5
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_compareTo_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.compareTo(null);
}
 
Example 6
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_compareTo_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.compareTo(null);
}
 
Example 7
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_compareTo_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.compareTo(null);
}
 
Example 8
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_compareTo_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.compareTo(null);
}
 
Example 9
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_compareTo_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.compareTo(null);
}
 
Example 10
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_compareTo_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.compareTo(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_compareTo_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.compareTo(null);
}
 
Example 12
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_compareTo_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.compareTo(null);
}
 
Example 13
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_compareTo_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.compareTo(null);
}
 
Example 14
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_compareTo_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.compareTo(null);
}
 
Example 15
Source File: TCKOffsetDateTime.java    From j2objc with Apache License 2.0 4 votes vote down vote up
@Test(expected=NullPointerException.class)
public void test_compareTo_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.compareTo(null);
}