Java 类org.joda.time.MutableInterval 实例源码

项目:TinyTravelTracker    文件:BaseInterval.java   
/**
 * Constructs a time interval converting or copying from another object
 * that describes an interval.
 * 
 * @param interval  the time interval to copy
 * @param chrono  the chronology to use, null means let converter decide
 * @throws IllegalArgumentException if the interval is invalid
 */
protected BaseInterval(Object interval, Chronology chrono) {
    super();
    IntervalConverter converter = ConverterManager.getInstance().getIntervalConverter(interval);
    if (converter.isReadableInterval(interval, chrono)) {
        ReadableInterval input = (ReadableInterval) interval;
        iChronology = (chrono != null ? chrono : input.getChronology());
        iStartMillis = input.getStartMillis();
        iEndMillis = input.getEndMillis();
    } else if (this instanceof ReadWritableInterval) {
        converter.setInto((ReadWritableInterval) this, interval, chrono);
    } else {
        MutableInterval mi = new MutableInterval();
        converter.setInto(mi, interval, chrono);
        iChronology = mi.getChronology();
        iStartMillis = mi.getStartMillis();
        iEndMillis = mi.getEndMillis();
    }
    checkInterval(iStartMillis, iEndMillis);
}
项目:astor    文件:BaseInterval.java   
/**
 * Constructs a time interval converting or copying from another object
 * that describes an interval.
 * 
 * @param interval  the time interval to copy
 * @param chrono  the chronology to use, null means let converter decide
 * @throws IllegalArgumentException if the interval is invalid
 */
protected BaseInterval(Object interval, Chronology chrono) {
    super();
    IntervalConverter converter = ConverterManager.getInstance().getIntervalConverter(interval);
    if (converter.isReadableInterval(interval, chrono)) {
        ReadableInterval input = (ReadableInterval) interval;
        iChronology = (chrono != null ? chrono : input.getChronology());
        iStartMillis = input.getStartMillis();
        iEndMillis = input.getEndMillis();
    } else if (this instanceof ReadWritableInterval) {
        converter.setInto((ReadWritableInterval) this, interval, chrono);
    } else {
        MutableInterval mi = new MutableInterval();
        converter.setInto(mi, interval, chrono);
        iChronology = mi.getChronology();
        iStartMillis = mi.getStartMillis();
        iEndMillis = mi.getEndMillis();
    }
    checkInterval(iStartMillis, iEndMillis);
}
项目:astor    文件:BaseInterval.java   
/**
 * Constructs a time interval converting or copying from another object
 * that describes an interval.
 * 
 * @param interval  the time interval to copy
 * @param chrono  the chronology to use, null means let converter decide
 * @throws IllegalArgumentException if the interval is invalid
 */
protected BaseInterval(Object interval, Chronology chrono) {
    super();
    IntervalConverter converter = ConverterManager.getInstance().getIntervalConverter(interval);
    if (converter.isReadableInterval(interval, chrono)) {
        ReadableInterval input = (ReadableInterval) interval;
        iChronology = (chrono != null ? chrono : input.getChronology());
        iStartMillis = input.getStartMillis();
        iEndMillis = input.getEndMillis();
    } else if (this instanceof ReadWritableInterval) {
        converter.setInto((ReadWritableInterval) this, interval, chrono);
    } else {
        MutableInterval mi = new MutableInterval();
        converter.setInto(mi, interval, chrono);
        iChronology = mi.getChronology();
        iStartMillis = mi.getStartMillis();
        iEndMillis = mi.getEndMillis();
    }
    checkInterval(iStartMillis, iEndMillis);
}
项目:idylfin    文件:BaseInterval.java   
/**
 * Constructs a time interval converting or copying from another object
 * that describes an interval.
 * 
 * @param interval  the time interval to copy
 * @param chrono  the chronology to use, null means let converter decide
 * @throws IllegalArgumentException if the interval is invalid
 */
protected BaseInterval(Object interval, Chronology chrono) {
    super();
    IntervalConverter converter = ConverterManager.getInstance().getIntervalConverter(interval);
    if (converter.isReadableInterval(interval, chrono)) {
        ReadableInterval input = (ReadableInterval) interval;
        iChronology = (chrono != null ? chrono : input.getChronology());
        iStartMillis = input.getStartMillis();
        iEndMillis = input.getEndMillis();
    } else if (this instanceof ReadWritableInterval) {
        converter.setInto((ReadWritableInterval) this, interval, chrono);
    } else {
        MutableInterval mi = new MutableInterval();
        converter.setInto(mi, interval, chrono);
        iChronology = mi.getChronology();
        iStartMillis = mi.getStartMillis();
        iEndMillis = mi.getEndMillis();
    }
    checkInterval(iStartMillis, iEndMillis);
}
项目:versemem-android    文件:BaseInterval.java   
/**
 * Constructs a time interval converting or copying from another object
 * that describes an interval.
 * 
 * @param interval  the time interval to copy
 * @param chrono  the chronology to use, null means let converter decide
 * @throws IllegalArgumentException if the interval is invalid
 */
protected BaseInterval(Object interval, Chronology chrono) {
    super();
    IntervalConverter converter = ConverterManager.getInstance().getIntervalConverter(interval);
    if (converter.isReadableInterval(interval, chrono)) {
        ReadableInterval input = (ReadableInterval) interval;
        iChronology = (chrono != null ? chrono : input.getChronology());
        iStartMillis = input.getStartMillis();
        iEndMillis = input.getEndMillis();
    } else if (this instanceof ReadWritableInterval) {
        converter.setInto((ReadWritableInterval) this, interval, chrono);
    } else {
        MutableInterval mi = new MutableInterval();
        converter.setInto(mi, interval, chrono);
        iChronology = mi.getChronology();
        iStartMillis = mi.getStartMillis();
        iEndMillis = mi.getEndMillis();
    }
    checkInterval(iStartMillis, iEndMillis);
}
项目:jfixture    文件:ReadableIntervalRelay.java   
@Override
public Object create(Object request, SpecimenContext context) {
    if (!(request.equals(ReadableInterval.class) || request.equals(ReadWritableInterval.class)))
        return new NoSpecimen();

    Interval interval = (Interval) context.resolve(Interval.class);
    return new MutableInterval(interval);
}
项目:jfixture    文件:TestAllClassDataTypesAreSupported.java   
@Test
public void creates_instance_of_MutableInterval() {
    MutableInterval interval = fixture.create(MutableInterval.class);
    assertThat(interval, notNullValue());
    assertThat(interval.getStart().toDate(), is(date));
    assertThat(interval.getEnd().toDate(), is(secondDate));
}
项目:astor    文件:TestNullConverter.java   
public void testSetInto_Object_Chronology1() throws Exception {
    MutableInterval m = new MutableInterval(1000L, 2000L, GJChronology.getInstance());
    NullConverter.INSTANCE.setInto(m, null, null);
    assertEquals(TEST_TIME_NOW, m.getStartMillis());
    assertEquals(TEST_TIME_NOW, m.getEndMillis());
    assertEquals(ISOChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestNullConverter.java   
public void testSetInto_Object_Chronology2() throws Exception {
    MutableInterval m = new MutableInterval(1000L, 2000L, GJChronology.getInstance());
    NullConverter.INSTANCE.setInto(m, null, CopticChronology.getInstance());
    assertEquals(TEST_TIME_NOW, m.getStartMillis());
    assertEquals(TEST_TIME_NOW, m.getEndMillis());
    assertEquals(CopticChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoInterval_Object_Chronology1() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "2004-06-09/P1Y2M", null);
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0), m.getStart());
    assertEquals(new DateTime(2005, 8, 9, 0, 0, 0, 0), m.getEnd());
    assertEquals(ISOChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoInterval_Object_Chronology2() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "P1Y2M/2004-06-09", null);
    assertEquals(new DateTime(2003, 4, 9, 0, 0, 0, 0), m.getStart());
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0), m.getEnd());
    assertEquals(ISOChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoInterval_Object_Chronology3() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "2003-08-09/2004-06-09", null);
    assertEquals(new DateTime(2003, 8, 9, 0, 0, 0, 0), m.getStart());
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0), m.getEnd());
    assertEquals(ISOChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoInterval_Object_Chronology4() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "2004-06-09T+06:00/P1Y2M", null);
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0, SIX).withChronology(null), m.getStart());
    assertEquals(new DateTime(2005, 8, 9, 0, 0, 0, 0, SIX).withChronology(null), m.getEnd());
    assertEquals(ISOChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoInterval_Object_Chronology5() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "P1Y2M/2004-06-09T+06:00", null);
    assertEquals(new DateTime(2003, 4, 9, 0, 0, 0, 0, SIX).withChronology(null), m.getStart());
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0, SIX).withChronology(null), m.getEnd());
    assertEquals(ISOChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoInterval_Object_Chronology6() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "2003-08-09T+06:00/2004-06-09T+07:00", null);
    assertEquals(new DateTime(2003, 8, 9, 0, 0, 0, 0, SIX).withChronology(null), m.getStart());
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0, SEVEN).withChronology(null), m.getEnd());
    assertEquals(ISOChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoInterval_Object_Chronology7() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "2003-08-09/2004-06-09", BuddhistChronology.getInstance());
    assertEquals(new DateTime(2003, 8, 9, 0, 0, 0, 0, BuddhistChronology.getInstance()), m.getStart());
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0, BuddhistChronology.getInstance()), m.getEnd());
    assertEquals(BuddhistChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoInterval_Object_Chronology8() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "2003-08-09T+06:00/2004-06-09T+07:00", BuddhistChronology.getInstance(EIGHT));
    assertEquals(new DateTime(2003, 8, 9, 0, 0, 0, 0, BuddhistChronology.getInstance(SIX)).withZone(EIGHT), m.getStart());
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0, BuddhistChronology.getInstance(SEVEN)).withZone(EIGHT), m.getEnd());
    assertEquals(BuddhistChronology.getInstance(EIGHT), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoIntervalEx_Object_Chronology1() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    try {
        StringConverter.INSTANCE.setInto(m, "", null);
        fail();
    } catch (IllegalArgumentException ex) {}
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoIntervalEx_Object_Chronology2() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    try {
        StringConverter.INSTANCE.setInto(m, "/", null);
        fail();
    } catch (IllegalArgumentException ex) {}
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoIntervalEx_Object_Chronology3() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    try {
        StringConverter.INSTANCE.setInto(m, "P1Y/", null);
        fail();
    } catch (IllegalArgumentException ex) {}
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoIntervalEx_Object_Chronology4() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    try {
        StringConverter.INSTANCE.setInto(m, "/P1Y", null);
        fail();
    } catch (IllegalArgumentException ex) {}
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoIntervalEx_Object_Chronology5() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    try {
        StringConverter.INSTANCE.setInto(m, "P1Y/P2Y", null);
        fail();
    } catch (IllegalArgumentException ex) {}
}
项目:astor    文件:TestReadableIntervalConverter.java   
public void testSetIntoInterval_Object1() throws Exception {
    Interval i = new Interval(0L, 123L, CopticChronology.getInstance());
    MutableInterval m = new MutableInterval(-1000L, 1000L, BuddhistChronology.getInstance());
    ReadableIntervalConverter.INSTANCE.setInto(m, i, null);
    assertEquals(0L, m.getStartMillis());
    assertEquals(123L, m.getEndMillis());
    assertEquals(CopticChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestReadableIntervalConverter.java   
public void testSetIntoInterval_Object2() throws Exception {
    Interval i = new Interval(0L, 123L, CopticChronology.getInstance());
    MutableInterval m = new MutableInterval(-1000L, 1000L, BuddhistChronology.getInstance());
    ReadableIntervalConverter.INSTANCE.setInto(m, i, GJChronology.getInstance());
    assertEquals(0L, m.getStartMillis());
    assertEquals(123L, m.getEndMillis());
    assertEquals(GJChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestReadableIntervalConverter.java   
public void testSetIntoInterval_Object3() throws Exception {
    MutableInterval i = new MutableInterval(0L, 123L) {
        public Chronology getChronology() {
            return null; // bad
        }
    };
    MutableInterval m = new MutableInterval(-1000L, 1000L, BuddhistChronology.getInstance());
    ReadableIntervalConverter.INSTANCE.setInto(m, i, GJChronology.getInstance());
    assertEquals(0L, m.getStartMillis());
    assertEquals(123L, m.getEndMillis());
    assertEquals(GJChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestReadableIntervalConverter.java   
public void testSetIntoInterval_Object4() throws Exception {
    MutableInterval i = new MutableInterval(0L, 123L) {
        public Chronology getChronology() {
            return null; // bad
        }
    };
    MutableInterval m = new MutableInterval(-1000L, 1000L, BuddhistChronology.getInstance());
    ReadableIntervalConverter.INSTANCE.setInto(m, i, null);
    assertEquals(0L, m.getStartMillis());
    assertEquals(123L, m.getEndMillis());
    assertEquals(ISOChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestNullConverter.java   
public void testSetInto_Object_Chronology1() throws Exception {
    MutableInterval m = new MutableInterval(1000L, 2000L, GJChronology.getInstance());
    NullConverter.INSTANCE.setInto(m, null, null);
    assertEquals(TEST_TIME_NOW, m.getStartMillis());
    assertEquals(TEST_TIME_NOW, m.getEndMillis());
    assertEquals(ISOChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestNullConverter.java   
public void testSetInto_Object_Chronology2() throws Exception {
    MutableInterval m = new MutableInterval(1000L, 2000L, GJChronology.getInstance());
    NullConverter.INSTANCE.setInto(m, null, CopticChronology.getInstance());
    assertEquals(TEST_TIME_NOW, m.getStartMillis());
    assertEquals(TEST_TIME_NOW, m.getEndMillis());
    assertEquals(CopticChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoInterval_Object_Chronology1() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "2004-06-09/P1Y2M", null);
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0), m.getStart());
    assertEquals(new DateTime(2005, 8, 9, 0, 0, 0, 0), m.getEnd());
    assertEquals(ISOChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoInterval_Object_Chronology2() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "P1Y2M/2004-06-09", null);
    assertEquals(new DateTime(2003, 4, 9, 0, 0, 0, 0), m.getStart());
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0), m.getEnd());
    assertEquals(ISOChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoInterval_Object_Chronology3() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "2003-08-09/2004-06-09", null);
    assertEquals(new DateTime(2003, 8, 9, 0, 0, 0, 0), m.getStart());
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0), m.getEnd());
    assertEquals(ISOChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoInterval_Object_Chronology4() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "2004-06-09T+06:00/P1Y2M", null);
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0, SIX).withChronology(null), m.getStart());
    assertEquals(new DateTime(2005, 8, 9, 0, 0, 0, 0, SIX).withChronology(null), m.getEnd());
    assertEquals(ISOChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoInterval_Object_Chronology5() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "P1Y2M/2004-06-09T+06:00", null);
    assertEquals(new DateTime(2003, 4, 9, 0, 0, 0, 0, SIX).withChronology(null), m.getStart());
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0, SIX).withChronology(null), m.getEnd());
    assertEquals(ISOChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoInterval_Object_Chronology6() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "2003-08-09T+06:00/2004-06-09T+07:00", null);
    assertEquals(new DateTime(2003, 8, 9, 0, 0, 0, 0, SIX).withChronology(null), m.getStart());
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0, SEVEN).withChronology(null), m.getEnd());
    assertEquals(ISOChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoInterval_Object_Chronology7() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "2003-08-09/2004-06-09", BuddhistChronology.getInstance());
    assertEquals(new DateTime(2003, 8, 9, 0, 0, 0, 0, BuddhistChronology.getInstance()), m.getStart());
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0, BuddhistChronology.getInstance()), m.getEnd());
    assertEquals(BuddhistChronology.getInstance(), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoInterval_Object_Chronology8() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "2003-08-09T+06:00/2004-06-09T+07:00", BuddhistChronology.getInstance(EIGHT));
    assertEquals(new DateTime(2003, 8, 9, 0, 0, 0, 0, BuddhistChronology.getInstance(SIX)).withZone(EIGHT), m.getStart());
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0, BuddhistChronology.getInstance(SEVEN)).withZone(EIGHT), m.getEnd());
    assertEquals(BuddhistChronology.getInstance(EIGHT), m.getChronology());
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoIntervalEx_Object_Chronology1() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    try {
        StringConverter.INSTANCE.setInto(m, "", null);
        fail();
    } catch (IllegalArgumentException ex) {}
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoIntervalEx_Object_Chronology2() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    try {
        StringConverter.INSTANCE.setInto(m, "/", null);
        fail();
    } catch (IllegalArgumentException ex) {}
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoIntervalEx_Object_Chronology3() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    try {
        StringConverter.INSTANCE.setInto(m, "P1Y/", null);
        fail();
    } catch (IllegalArgumentException ex) {}
}
项目:astor    文件:TestStringConverter.java   
public void testSetIntoIntervalEx_Object_Chronology4() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    try {
        StringConverter.INSTANCE.setInto(m, "/P1Y", null);
        fail();
    } catch (IllegalArgumentException ex) {}
}