当前位置: 首页>>代码示例>>Java>>正文


Java DateTime.plusMillis方法代码示例

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


在下文中一共展示了DateTime.plusMillis方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testIsTurnOffTime

import org.joda.time.DateTime; //导入方法依赖的package包/类
@Test
public void testIsTurnOffTime() {
	LampDTO lampDTO = new LampDTO();
	lampDTO.setWorkingStart(DateTime.now().withMillisOfDay(0).withHourOfDay(7).toDate());
	lampDTO.setWorkingEnd(DateTime.now().withMillisOfDay(0).withHourOfDay(19).toDate());
	
	
	
	DateTime beerOClock = DateTime.now().withHourOfDay(20);
	assertTrue(jobListener.isTurnOffTime(lampDTO, beerOClock));
	
	DateTime earlyInTheMorning = DateTime.now().withHourOfDay(5);
	assertTrue(jobListener.isTurnOffTime(lampDTO, earlyInTheMorning));
	
	DateTime hardWorkingTime = DateTime.now().withHourOfDay(10);
	assertFalse(jobListener.isTurnOffTime(lampDTO, hardWorkingTime));
	
	
	
	DateTime workingStart = DateTime.now().withMillisOfDay(0).withHourOfDay(7);
	assertFalse(jobListener.isTurnOffTime(lampDTO, workingStart));
	
	DateTime beforeWorkingStart = workingStart.minusMillis(1);
	assertTrue(jobListener.isTurnOffTime(lampDTO, beforeWorkingStart));
	
	DateTime afterWorkingStart = workingStart.plusMillis(1);
	assertFalse(jobListener.isTurnOffTime(lampDTO, afterWorkingStart));
	
	
	
	DateTime workingEnd = DateTime.now().withMillisOfDay(0).withHourOfDay(19);
	assertFalse(jobListener.isTurnOffTime(lampDTO, workingEnd));
	
	DateTime beforeWorkingEnd = workingEnd.minusMillis(1);
	assertFalse(jobListener.isTurnOffTime(lampDTO, beforeWorkingEnd));
	
	DateTime afterWorkingEnd = workingEnd.plusMillis(1);
	assertTrue(jobListener.isTurnOffTime(lampDTO, afterWorkingEnd));
}
 
开发者ID:adessoAG,项目名称:JenkinsHue,代码行数:40,代码来源:JobListenerTest.java


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