• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ReadableInterval类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.joda.time.ReadableInterval的典型用法代码示例。如果您正苦于以下问题:Java ReadableInterval类的具体用法?Java ReadableInterval怎么用?Java ReadableInterval使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ReadableInterval类属于org.joda.time包,在下文中一共展示了ReadableInterval类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: BaseInterval

import org.joda.time.ReadableInterval; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:28,代码来源:BaseInterval.java


示例2: testGetDurationConverter

import org.joda.time.ReadableInterval; //导入依赖的package包/类
public void testGetDurationConverter() {
    DurationConverter c = ConverterManager.getInstance().getDurationConverter(new Long(0L));
    assertEquals(Long.class, c.getSupportedType());
    
    c = ConverterManager.getInstance().getDurationConverter(new Duration(123L));
    assertEquals(ReadableDuration.class, c.getSupportedType());
    
    c = ConverterManager.getInstance().getDurationConverter(new Interval(0L, 1000L));
    assertEquals(ReadableInterval.class, c.getSupportedType());
    
    c = ConverterManager.getInstance().getDurationConverter("");
    assertEquals(String.class, c.getSupportedType());
    
    c = ConverterManager.getInstance().getDurationConverter(null);
    assertEquals(null, c.getSupportedType());
    
    try {
        ConverterManager.getInstance().getDurationConverter(Boolean.TRUE);
        fail();
    } catch (IllegalArgumentException ex) {}
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:22,代码来源:TestConverterManager.java


示例3: testGetPeriodConverter

import org.joda.time.ReadableInterval; //导入依赖的package包/类
public void testGetPeriodConverter() {
    PeriodConverter c = ConverterManager.getInstance().getPeriodConverter(new Period(1, 2, 3, 4, 5, 6, 7, 8));
    assertEquals(ReadablePeriod.class, c.getSupportedType());
    
    c = ConverterManager.getInstance().getPeriodConverter(new Duration(123L));
    assertEquals(ReadableDuration.class, c.getSupportedType());
    
    c = ConverterManager.getInstance().getPeriodConverter(new Interval(0L, 1000L));
    assertEquals(ReadableInterval.class, c.getSupportedType());
    
    c = ConverterManager.getInstance().getPeriodConverter("");
    assertEquals(String.class, c.getSupportedType());
    
    c = ConverterManager.getInstance().getPeriodConverter(null);
    assertEquals(null, c.getSupportedType());
    
    try {
        ConverterManager.getInstance().getPeriodConverter(Boolean.TRUE);
        fail();
    } catch (IllegalArgumentException ex) {}
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:22,代码来源:TestConverterManager.java


示例4: contains

import org.joda.time.ReadableInterval; //导入依赖的package包/类
/**
 * Does a time interval contain a specified time interval.
 * 
 * @param interval the interval to check
 * @param intervalCompareTo the interval to compare to
 * @return true if this time ' intervalCompareTo' contains 'intervalCompareTo'
 */
public static boolean contains(ReadableInterval interval, ReadableInterval intervalCompareTo) {
    if (intervalCompareTo == null) {
        return DateUtils.containsNow(intervalCompareTo);
    }
    long otherStart = intervalCompareTo.getStartMillis();
    long otherEnd = intervalCompareTo.getEndMillis();
    long thisStart = interval.getStartMillis();
    long thisEnd = interval.getEndMillis();
    return (thisStart <= otherStart && otherStart <= thisEnd && otherEnd <= thisEnd);
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:18,代码来源:DateUtils.java


示例5: intersects

import org.joda.time.ReadableInterval; //导入依赖的package包/类
/**
 * Does a time interval intersect another time interval.
 * <p>
 * 
 * @param interval1 the interval1
 * @param interval2 the interval2
 * @return true if the time intervals intersect
 */
public static boolean intersects(ReadableInterval interval1, ReadableInterval interval2) {

    if (interval1 == null) {
        return false;
    }
    if (interval2 == null) {
        return false;
    }
    long thisStart = interval1.getStartMillis();
    long thisEnd = interval1.getEndMillis();
    long otherStart = interval2.getStartMillis();
    long otherEnd = interval2.getEndMillis();
    return (thisStart <= otherEnd && otherStart <= thisEnd);
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:23,代码来源:DateUtils.java


示例6: intersect

import org.joda.time.ReadableInterval; //导入依赖的package包/类
public static Interval intersect(ReadableInterval interval1, ReadableInterval interval2) {
    if (DateUtils.intersects(interval1, interval2) == false) {
        return null;
    }
    long start = Math.max(interval1.getStartMillis(), interval2.getStartMillis());
    long end = Math.min(interval1.getEndMillis(), interval2.getEndMillis());
    return new Interval(start, end);
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:9,代码来源:DateUtils.java


示例7: isAfter

import org.joda.time.ReadableInterval; //导入依赖的package包/类
/**
 * Is this time interval entirely after the specified interval.
 * <p>
 * Intervals are inclusive of the start instant and exclusive of the end.
 * Only the end time of the specified interval is used in the comparison.
 * 
 * @param interval  the interval to compare to, null means now
 * @return true if this time interval is after the interval specified
 */
public boolean isAfter(ReadableInterval interval) {
    long endMillis;
    if (interval == null) {
        endMillis = DateTimeUtils.currentTimeMillis();
    } else {
        endMillis = interval.getEndMillis();
    }
    return (getStartMillis() >= endMillis);
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:19,代码来源:AbstractInterval.java


示例8: equals

import org.joda.time.ReadableInterval; //导入依赖的package包/类
/**
 * Compares this object with the specified object for equality based
 * on start and end millis plus the chronology.
 * All ReadableInterval instances are accepted.
 * <p>
 * To compare the duration of two time intervals, use {@link #toDuration()}
 * to get the durations and compare those.
 *
 * @param readableInterval  a readable interval to check against
 * @return true if the start and end millis are equal
 */
public boolean equals(Object readableInterval) {
    if (this == readableInterval) {
        return true;
    }
    if (readableInterval instanceof ReadableInterval == false) {
        return false;
    }
    ReadableInterval other = (ReadableInterval) readableInterval;
    return 
        getStartMillis() == other.getStartMillis() &&
        getEndMillis() == other.getEndMillis() &&
        FieldUtils.equals(getChronology(), other.getChronology());
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:25,代码来源:AbstractInterval.java


示例9: setInto

import org.joda.time.ReadableInterval; //导入依赖的package包/类
/**
 * Sets the values of the mutable duration from the specified interval.
 * 
 * @param writablePeriod  the period to modify
 * @param object  the interval to set from
 * @param chrono  the chronology to use
 */
public void setInto(ReadWritablePeriod writablePeriod, Object object, Chronology chrono) {
    ReadableInterval interval = (ReadableInterval) object;
    chrono = (chrono != null ? chrono : DateTimeUtils.getIntervalChronology(interval));
    long start = interval.getStartMillis();
    long end = interval.getEndMillis();
    int[] values = chrono.get(writablePeriod, start, end);
    for (int i = 0; i < values.length; i++) {
        writablePeriod.setValue(i, values[i]);
    }
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:18,代码来源:ReadableIntervalConverter.java


示例10: create

import org.joda.time.ReadableInterval; //导入依赖的package包/类
@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);
}
 
开发者ID:FlexTradeUKLtd,项目名称:jfixture,代码行数:9,代码来源:ReadableIntervalRelay.java


示例11: creates_instance_of_ReadableInterval

import org.joda.time.ReadableInterval; //导入依赖的package包/类
@Test
public void creates_instance_of_ReadableInterval() throws ParseException {
    ReadableInterval interval = fixture.create(ReadableInterval.class);
    assertThat(interval, notNullValue());
    assertThat(interval.getStart().toDate(), is(date));
    assertThat(interval.getEnd().toDate(), is(secondDate));
}
 
开发者ID:FlexTradeUKLtd,项目名称:jfixture,代码行数:8,代码来源:TestAllInterfaceDataTypesAreSupported.java


示例12: equals

import org.joda.time.ReadableInterval; //导入依赖的package包/类
/**
 * Compares this object with the specified object for equality based
 * on start and end millis plus the chronology.
 * All ReadableInterval instances are accepted.
 * <p>
 * To compare the duration of two time intervals, use {@link #toDuration()}
 * to get the durations and compare those.
 *
 * @param readableInterval  a readable interval to check against
 * @return true if the intervals are equal comparing the start millis,
 *  end millis and chronology
 */
public boolean equals(Object readableInterval) {
    if (this == readableInterval) {
        return true;
    }
    if (readableInterval instanceof ReadableInterval == false) {
        return false;
    }
    ReadableInterval other = (ReadableInterval) readableInterval;
    return 
        getStartMillis() == other.getStartMillis() &&
        getEndMillis() == other.getEndMillis() &&
        FieldUtils.equals(getChronology(), other.getChronology());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:26,代码来源:AbstractInterval.java


示例13: getSupportedType

import org.joda.time.ReadableInterval; //导入依赖的package包/类
/**
 * Returns ReadableInterval.class.
 */
public Class<?> getSupportedType() {
    return ReadableInterval.class;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:7,代码来源:ReadableIntervalConverter.java


示例14: testSupportedType

import org.joda.time.ReadableInterval; //导入依赖的package包/类
public void testSupportedType() throws Exception {
    assertEquals(ReadableInterval.class, ReadableIntervalConverter.INSTANCE.getSupportedType());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:4,代码来源:TestReadableIntervalConverter.java



注:本文中的org.joda.time.ReadableInterval类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Callback类代码示例发布时间:2022-05-23
下一篇:
Java LayeredBarRenderer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap