Java Code Examples for org.joda.time.DurationFieldType#seconds()

The following examples show how to use org.joda.time.DurationFieldType#seconds() . 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: TestMillisDurationField.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void test_compareTo() {
        assertEquals(0, MillisDurationField.INSTANCE.compareTo(MillisDurationField.INSTANCE));
        assertEquals(-1, MillisDurationField.INSTANCE.compareTo(ISOChronology.getInstance().seconds()));
        DurationField dummy = new PreciseDurationField(DurationFieldType.seconds(), 0);
        assertEquals(1, MillisDurationField.INSTANCE.compareTo(dummy));
//        try {
//            MillisDurationField.INSTANCE.compareTo("");
//            fail();
//        } catch (ClassCastException ex) {}
        try {
            MillisDurationField.INSTANCE.compareTo(null);
            fail();
        } catch (NullPointerException ex) {}
    }
 
Example 2
Source File: TestPreciseDurationField.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void test_equals() {
    assertEquals(true, iField.equals(iField));
    assertEquals(false, iField.equals(ISOChronology.getInstance().minutes()));
    DurationField dummy = new PreciseDurationField(DurationFieldType.seconds(), 0);
    assertEquals(false, iField.equals(dummy));
    dummy = new PreciseDurationField(DurationFieldType.seconds(), 1000);
    assertEquals(true, iField.equals(dummy));
    dummy = new PreciseDurationField(DurationFieldType.millis(), 1000);
    assertEquals(false, iField.equals(dummy));
    assertEquals(false, iField.equals(""));
    assertEquals(false, iField.equals(null));
}
 
Example 3
Source File: TestPreciseDurationField.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void test_hashCode() {
    assertEquals(true, iField.hashCode() == iField.hashCode());
    assertEquals(false, iField.hashCode() == ISOChronology.getInstance().minutes().hashCode());
    DurationField dummy = new PreciseDurationField(DurationFieldType.seconds(), 0);
    assertEquals(false, iField.hashCode() == dummy.hashCode());
    dummy = new PreciseDurationField(DurationFieldType.seconds(), 1000);
    assertEquals(true, iField.hashCode() == dummy.hashCode());
    dummy = new PreciseDurationField(DurationFieldType.millis(), 1000);
    assertEquals(false, iField.hashCode() == dummy.hashCode());
}
 
Example 4
Source File: TestPreciseDurationField.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void test_compareTo() {
        assertEquals(0, iField.compareTo(iField));
        assertEquals(-1, iField.compareTo(ISOChronology.getInstance().minutes()));
        DurationField dummy = new PreciseDurationField(DurationFieldType.seconds(), 0);
        assertEquals(1, iField.compareTo(dummy));
//        try {
//            iField.compareTo("");
//            fail();
//        } catch (ClassCastException ex) {}
        try {
            iField.compareTo(null);
            fail();
        } catch (NullPointerException ex) {}
    }
 
Example 5
Source File: TestMillisDurationField.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void test_compareTo() {
        assertEquals(0, MillisDurationField.INSTANCE.compareTo(MillisDurationField.INSTANCE));
        assertEquals(-1, MillisDurationField.INSTANCE.compareTo(ISOChronology.getInstance().seconds()));
        DurationField dummy = new PreciseDurationField(DurationFieldType.seconds(), 0);
        assertEquals(1, MillisDurationField.INSTANCE.compareTo(dummy));
//        try {
//            MillisDurationField.INSTANCE.compareTo("");
//            fail();
//        } catch (ClassCastException ex) {}
        try {
            MillisDurationField.INSTANCE.compareTo(null);
            fail();
        } catch (NullPointerException ex) {}
    }
 
Example 6
Source File: TestPreciseDurationField.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void test_equals() {
    assertEquals(true, iField.equals(iField));
    assertEquals(false, iField.equals(ISOChronology.getInstance().minutes()));
    DurationField dummy = new PreciseDurationField(DurationFieldType.seconds(), 0);
    assertEquals(false, iField.equals(dummy));
    dummy = new PreciseDurationField(DurationFieldType.seconds(), 1000);
    assertEquals(true, iField.equals(dummy));
    dummy = new PreciseDurationField(DurationFieldType.millis(), 1000);
    assertEquals(false, iField.equals(dummy));
    assertEquals(false, iField.equals(""));
    assertEquals(false, iField.equals(null));
}
 
Example 7
Source File: TestPreciseDurationField.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void test_hashCode() {
    assertEquals(true, iField.hashCode() == iField.hashCode());
    assertEquals(false, iField.hashCode() == ISOChronology.getInstance().minutes().hashCode());
    DurationField dummy = new PreciseDurationField(DurationFieldType.seconds(), 0);
    assertEquals(false, iField.hashCode() == dummy.hashCode());
    dummy = new PreciseDurationField(DurationFieldType.seconds(), 1000);
    assertEquals(true, iField.hashCode() == dummy.hashCode());
    dummy = new PreciseDurationField(DurationFieldType.millis(), 1000);
    assertEquals(false, iField.hashCode() == dummy.hashCode());
}
 
Example 8
Source File: TestPreciseDurationField.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void test_compareTo() {
        assertEquals(0, iField.compareTo(iField));
        assertEquals(-1, iField.compareTo(ISOChronology.getInstance().minutes()));
        DurationField dummy = new PreciseDurationField(DurationFieldType.seconds(), 0);
        assertEquals(1, iField.compareTo(dummy));
//        try {
//            iField.compareTo("");
//            fail();
//        } catch (ClassCastException ex) {}
        try {
            iField.compareTo(null);
            fail();
        } catch (NullPointerException ex) {}
    }
 
Example 9
Source File: TestPreciseDurationDateTimeField.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
protected MockPreciseDurationDateTimeField() {
    super(DateTimeFieldType.secondOfMinute(),
        new MockCountingDurationField(DurationFieldType.seconds()));
}
 
Example 10
Source File: TestPreciseDateTimeField.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
protected MockPreciseDateTimeField() {
    super(DateTimeFieldType.secondOfMinute(),
        new MockCountingDurationField(DurationFieldType.seconds(), 60),
        new MockCountingDurationField(DurationFieldType.minutes(), 60 * 60));
}
 
Example 11
Source File: TestPreciseDurationField.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
protected void setUp() throws Exception {
    iField = new PreciseDurationField(DurationFieldType.seconds(), 1000);
}
 
Example 12
Source File: TestBaseDateTimeField.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public DurationField getDurationField() {
    return new MockCountingDurationField(DurationFieldType.seconds());
}
 
Example 13
Source File: TestPreciseDurationDateTimeField.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
protected MockPreciseDurationDateTimeField() {
    super(DateTimeFieldType.secondOfMinute(),
        new MockCountingDurationField(DurationFieldType.seconds()));
}
 
Example 14
Source File: TestPreciseDateTimeField.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
protected MockPreciseDateTimeField() {
    super(DateTimeFieldType.secondOfMinute(),
        new MockCountingDurationField(DurationFieldType.seconds(), 60),
        new MockCountingDurationField(DurationFieldType.minutes(), 60 * 60));
}
 
Example 15
Source File: TestPreciseDurationField.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
protected void setUp() throws Exception {
    iField = new PreciseDurationField(DurationFieldType.seconds(), 1000);
}
 
Example 16
Source File: TestBaseDateTimeField.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public DurationField getDurationField() {
    return new MockCountingDurationField(DurationFieldType.seconds());
}