本文整理汇总了Java中org.joda.time.base.AbstractInstant类的典型用法代码示例。如果您正苦于以下问题:Java AbstractInstant类的具体用法?Java AbstractInstant怎么用?Java AbstractInstant使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractInstant类属于org.joda.time.base包,在下文中一共展示了AbstractInstant类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: makeTimer
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
/**
* helper function to create the timer
* @param instant the point in time when the code should be executed
* @param closure string for job id
* @param dataMap job data map, preconfigured with arguments
* @return
*/
private static Timer makeTimer(AbstractInstant instant, String closure, JobDataMap dataMap) {
JobKey jobKey = new JobKey(instant.toString() + ": " + closure.toString());
Trigger trigger = newTrigger().startAt(instant.toDate()).build();
Timer timer = new TimerImpl(jobKey, trigger.getKey(), instant);
dataMap.put("timer", timer);
try {
JobDetail job = newJob(TimerExecutionJob.class)
.withIdentity(jobKey)
.usingJobData(dataMap)
.build();
TimerImpl.scheduler.scheduleJob(job, trigger);
logger.debug("Scheduled code for execution at {}", instant.toString());
return timer;
} catch(SchedulerException e) {
logger.error("Failed to schedule code for execution.", e);
return null;
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:27,代码来源:ScriptExecution.java
示例2: historicState
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
/**
* Retrieves the state of a given <code>item</code> to a certain point in time through a {@link PersistenceService} identified
* by the <code>serviceName</code>.
*
* @param item the item to retrieve the state for
* @param the point in time for which the state should be retrieved
* @param serviceName the name of the {@link PersistenceService} to use
* @return the item state at the given point in time
*/
static public HistoricItem historicState(Item item, AbstractInstant timestamp, String serviceName) {
PersistenceService service = services.get(serviceName);
if (service instanceof QueryablePersistenceService) {
QueryablePersistenceService qService = (QueryablePersistenceService) service;
FilterCriteria filter = new FilterCriteria();
filter.setEndDate(timestamp.toDate());
filter.setItemName(item.getName());
filter.setPageSize(1);
filter.setOrdering(Ordering.DESCENDING);
Iterable<HistoricItem> result = qService.query(filter);
if(result.iterator().hasNext()) {
return result.iterator().next();
} else {
return null;
}
} else {
logger.warn("There is no queryable persistence service registered with the name '{}'", serviceName);
return null;
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:30,代码来源:PersistenceExtensions.java
示例3: changedSince
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
/**
* Checks if the state of a given <code>item</code> has changed since a certain point in time.
* The {@link PersistenceService} identified by the <code>serviceName</code> is used.
*
* @param item the item to check for state changes
* @param the point in time to start the check
* @param serviceName the name of the {@link PersistenceService} to use
* @return true, if item state had changed
*/
static public Boolean changedSince(Item item, AbstractInstant timestamp, String serviceName) {
Iterable<HistoricItem> result = getAllStatesSince(item, timestamp, serviceName);
Iterator<HistoricItem> it = result.iterator();
HistoricItem itemThen = historicState(item, timestamp);
if(itemThen == null) {
// Can't get the state at the start time
// If we've got results more recent that this, it must have changed
return(it.hasNext());
}
State state = itemThen.getState();
while(it.hasNext()) {
HistoricItem hItem = it.next();
if(state!=null && !hItem.getState().equals(state)) {
return true;
}
state = hItem.getState();
}
return false;
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:30,代码来源:PersistenceExtensions.java
示例4: sumSince
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
/**
* Gets the sum of the state of a given <code>item</code> since a certain point in time.
* The {@link PersistenceService} identified by the <code>serviceName</code> is used.
*
* @param item the item to get the average state value for
* @param the point in time to start the check
* @param serviceName the name of the {@link PersistenceService} to use
* @return the sum state value since the given point in time
*/
static public DecimalType sumSince(Item item, AbstractInstant timestamp, String serviceName) {
Iterable<HistoricItem> result = getAllStatesSince(item, timestamp, serviceName);
Iterator<HistoricItem> it = result.iterator();
double sum = 0;
while(it.hasNext()) {
State state = it.next().getState();
if (state instanceof DecimalType) {
sum += ((DecimalType) state).doubleValue();
}
}
return new DecimalType(sum);
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:25,代码来源:PersistenceExtensions.java
示例5: main
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
public static void main(String[] args) {
System.out.println("-----------------------------------------------");
System.out.println("-----------AbstractInstant---------------------");
Class cls = AbstractInstant.class;
System.out.println("-----------ReadableDateTime--------------------");
cls = ReadableDateTime.class;
System.out.println("-----------AbstractDateTime--------------------");
cls = AbstractDateTime.class;
System.out.println("-----------DateTime----------------------------");
cls = DateTime.class;
System.out.println("-----------DateTimeZone------------------------");
cls = DateTimeZone.class;
System.out.println("-----------new DateTime()----------------------");
DateTime dt = new DateTime();
System.out.println("-----------new DateTime(ReadableInstant)-------");
dt = new DateTime(dt);
System.out.println("-----------new DateTime(Long)------------------");
dt = new DateTime(new Long(0));
System.out.println("-----------------------------------------------");
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:ClassLoadTest.java
示例6: testGetInstantChronology_RI
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
public void testGetInstantChronology_RI() {
DateTime dt = new DateTime(123L, BuddhistChronology.getInstance());
assertEquals(BuddhistChronology.getInstance(), DateTimeUtils.getInstantChronology(dt));
Instant i = new Instant(123L);
assertEquals(ISOChronology.getInstanceUTC(), DateTimeUtils.getInstantChronology(i));
AbstractInstant ai = new AbstractInstant() {
public long getMillis() {
return 0L;
}
public Chronology getChronology() {
return null; // testing for this
}
};
assertEquals(ISOChronology.getInstance(), DateTimeUtils.getInstantChronology(ai));
assertEquals(ISOChronology.getInstance(), DateTimeUtils.getInstantChronology(null));
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:20,代码来源:TestDateTimeUtils.java
示例7: getPreviousValue
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
protected HistoricItem getPreviousValue(Item theItem) {
DateTime now = new DateTime();
AbstractInstant earlier = now.minusHours(6);
if (persistenceService == null) {
return PersistenceExtensions.historicState(theItem, earlier);
} else {
return PersistenceExtensions.historicState(theItem, earlier, persistenceService);
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:10,代码来源:SagerCasterBinding.java
示例8: reschedule
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
public boolean reschedule(AbstractInstant newTime) {
try {
Trigger trigger = newTrigger().startAt(newTime.toDate()).build();
scheduler.rescheduleJob(triggerKey, trigger);
this.triggerKey = trigger.getKey();
this.cancelled = false;
this.terminated = false;
return true;
} catch (SchedulerException e) {
logger.warn("An error occured while rescheduling the job '{}': {}", new String[] { jobKey.toString(), e.getMessage() });
return false;
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:14,代码来源:TimerImpl.java
示例9: makeTimer
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
private static Timer makeTimer(AbstractInstant instant, String closure, JobDataMap dataMap) {
JobKey jobKey = new JobKey(instant.toString() + ": " + closure.toString());
Trigger trigger = newTrigger().startAt(instant.toDate()).build();
Timer timer = new Timer(jobKey, trigger.getKey(), instant);
dataMap.put("timer", timer);
try {
JobDetail job = newJob(TimerExecutionJob.class).withIdentity(jobKey).usingJobData(dataMap).build();
Timer.scheduler.scheduleJob(job, trigger);
logger.debug("Scheduled code for execution at {}", instant.toString());
return timer;
} catch (SchedulerException e) {
logger.error("Failed to schedule code for execution.", e);
return null;
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:16,代码来源:Openhab.java
示例10: reschedule
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
public boolean reschedule(AbstractInstant newTime) {
try {
Trigger trigger = newTrigger().startAt(newTime.toDate()).build();
scheduler.rescheduleJob(triggerKey, trigger);
this.triggerKey = trigger.getKey();
this.cancelled = false;
this.terminated = false;
return true;
} catch (SchedulerException e) {
logger.warn("An error occured while rescheduling the job '{}': {}", new String[] { jobKey.toString(), e.getMessage() });
return false;
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:14,代码来源:Timer.java
示例11: getAllStatesSince
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
static private Iterable<HistoricItem> getAllStatesSince(Item item, AbstractInstant timestamp, String serviceName) {
PersistenceService service = services.get(serviceName);
if (service instanceof QueryablePersistenceService) {
QueryablePersistenceService qService = (QueryablePersistenceService) service;
FilterCriteria filter = new FilterCriteria();
filter.setBeginDate(timestamp.toDate());
filter.setItemName(item.getName());
filter.setOrdering(Ordering.ASCENDING);
return qService.query(filter);
} else {
logger.warn("There is no queryable persistence service registered with the name '{}'", serviceName);
return Collections.emptySet();
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:15,代码来源:PersistenceExtensions.java
示例12: format
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
@Override
public String format(final AbstractInstant target, String pattern) {
try {
return DateTimeFormat.forPattern(pattern).withLocale(locale).print(target);
} catch (final Exception e) {
throw new TemplateProcessingException(
"Error formatting Joda DateTime with pattern '" + pattern + "' for locale " + this.locale, e);
}
}
开发者ID:eveoh,项目名称:thymeleaf-joda,代码行数:10,代码来源:JodaImpl.java
示例13: extractLastApprovedOrRejectDate
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
DateTime extractLastApprovedOrRejectDate(List<StatusChange> statusChangeHistory) {
return statusChangeHistory.stream()
.filter(statusChange -> asList(Status.APPROVED, Status.REJECTED).contains(statusChange.getTo()))
.map(StatusChange::getChangedOn)
.max(AbstractInstant::compareTo)
.orElseGet(() -> null);
}
开发者ID:obiba,项目名称:mica2,代码行数:8,代码来源:CsvReportGenerator.java
示例14: extractFirstSubmissionDate
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
DateTime extractFirstSubmissionDate(List<StatusChange> statusChangeHistory) {
return statusChangeHistory.stream()
.filter(statusChange -> Status.SUBMITTED.equals(statusChange.getTo()))
.map(StatusChange::getChangedOn)
.min(AbstractInstant::compareTo)
.orElseGet(() -> null);
}
开发者ID:obiba,项目名称:mica2,代码行数:8,代码来源:CsvReportGenerator.java
示例15: getPreviousValue
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
protected HistoricItem getPreviousValue(Item theItem) {
DateTime now = new DateTime();
AbstractInstant earlier = now.minusHours(6);
if (persistenceService == null) {
return PersistenceExtensions.historicState(theItem, earlier);
} else {
return PersistenceExtensions.historicState(theItem, earlier, persistenceService);
}
}
开发者ID:openhab,项目名称:openhab1-addons,代码行数:10,代码来源:SagerCasterBinding.java
示例16: setLastModifiedDate
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
/**
* Sets last modified date.
*
* @param lastModifiedDate the last modified date
*/
public void setLastModifiedDate(final DateTime lastModifiedDate) {
this.lastModifiedDate = Optional.ofNullable(lastModifiedDate)
.map(AbstractInstant::toDate)
.orElse(null);
}
开发者ID:mhaddon,项目名称:Sound.je,代码行数:11,代码来源:AuditedEntity.java
示例17: TimerImpl
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
public TimerImpl(JobKey jobKey, TriggerKey triggerKey, AbstractInstant startTime) {
this.jobKey = jobKey;
this.triggerKey = triggerKey;
this.startTime = startTime;
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:6,代码来源:TimerImpl.java
示例18: createTimer
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
public static Timer createTimer(AbstractInstant instant, Runnable closure) {
JobDataMap dataMap = new JobDataMap();
dataMap.put("procedure", closure);
return makeTimer(instant, closure.toString(), dataMap);
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:6,代码来源:Openhab.java
示例19: Timer
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
public Timer(JobKey jobKey, TriggerKey triggerKey, AbstractInstant startTime) {
this.jobKey = jobKey;
this.triggerKey = triggerKey;
this.startTime = startTime;
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:6,代码来源:Timer.java
示例20: timestampsBeforeNow
import org.joda.time.base.AbstractInstant; //导入依赖的package包/类
public static Stream<String> timestampsBeforeNow( DateTime since ) {
return Stream.of( since, AbstractInstant::isBeforeNow, t -> t.plusMinutes( 60 / BUCKETS_PER_HOUR ) )
.map( Timestamp::format );
}
开发者ID:oaplatform,项目名称:oap,代码行数:5,代码来源:Timestamp.java
注:本文中的org.joda.time.base.AbstractInstant类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论