org.opennms.netmgt.xml.event.Event.getTime()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(189)

本文整理了Java中org.opennms.netmgt.xml.event.Event.getTime()方法的一些代码示例,展示了Event.getTime()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Event.getTime()方法的具体详情如下:
包路径:org.opennms.netmgt.xml.event.Event
类名称:Event
方法名:getTime

Event.getTime介绍

[英]Returns the value of field 'time'. The field 'time' has the following description: The time at which this event was generated. The time is in the format generated by the java.text.DateFormat using the DateFormat#FULL style for the default locale. For example: "Monday, February 18, 2002 3:01:58 PM EST" Known Issues: This field doesn't have millisecond resolution because we are using DateFormat#FULL.
[中]返回字段“time”的值。“时间”字段具有以下描述:生成此事件的时间。时间采用java生成的格式。文本DateFormat使用默认区域设置的DateFormat#完整样式。例如:“美国东部时间2002年2月18日星期一下午3:01:58”已知问题:此字段没有毫秒分辨率,因为我们使用的是DateFormat#FULL。

代码示例

代码示例来源:origin: OpenNMS/opennms

@Override
public Date getTime() {
  return event.getTime();
}

代码示例来源:origin: stackoverflow.com

public class Event implements Comparable<Event>{

  //removed fields and methods

  @Override
  public int compareTo(Event event){
    return this.getTime().compareTo(event.getTime());
  }

}

代码示例来源:origin: OpenNMS/opennms

@Override
  public String getValue(String parm, String parsedParm, Event event, EventUtil eventUtil) {
    Date eventTime = event.getTime(); // This will be in GMT
    if (eventTime != null) {
      DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
      return df.format(eventTime);
    }
    return null;
  }
},

代码示例来源:origin: OpenNMS/opennms

@Override
  public String getValue(String parm, String parsedParm, Event event, EventUtil eventUtil) {
    Date eventTime = event.getTime(); //This will be in GMT
    if (eventTime != null) {
      DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
      return df.format(eventTime);
    }
    return null;
  }
},

代码示例来源:origin: org.opennms.features.events/org.opennms.features.events.daemon

@Override
  public String getValue(String parm, String parsedParm, Event event, EventUtil eventUtil) {
    Date eventTime = event.getTime(); // This will be in GMT
    if (eventTime != null) {
      DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
      return df.format(eventTime);
    }
    return null;
  }
},

代码示例来源:origin: org.opennms.features.events/org.opennms.features.events.daemon

@Override
  public String getValue(String parm, String parsedParm, Event event, EventUtil eventUtil) {
    Date eventTime = event.getTime(); //This will be in GMT
    if (eventTime != null) {
      DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
      return df.format(eventTime);
    }
    return null;
  }
},

代码示例来源:origin: OpenNMS/opennms

public Date currentEventTime() {
  if (m_event.getTime() == null && zonedDateTimeBuilder != null) {
    ZonedDateTime time = zonedDateTimeBuilder.build();
    return Date.from(time.toInstant());
  } else {
    return m_event.getTime();
  }
}

代码示例来源:origin: stackoverflow.com

public int compare(Event e1, Event e2) {
  int cmp = e1.getTime() - e2.getTime(); // compare times
  if (cmp == 0)  // if times are equal, compare names instead
    cmp = e1.getName().compareTo(e2.getName());
  return SORT_DESCENDING.equals(_sortOrder)? -cmp : cmp;
}

代码示例来源:origin: OpenNMS/opennms

/**
 * <p>Constructor for PendingPollEvent.</p>
 *
 * @param event a {@link org.opennms.netmgt.xml.event.Event} object.
 */
public PendingPollEvent(final Event event) {
  super(Scope.fromUei(event.getUei()));
  m_event = event;
  m_date = m_event.getTime();
  m_expirationTimeInMillis = m_date.getTime() + PENDING_EVENT_TIMEOUT;
}

代码示例来源:origin: OpenNMS/opennms

public void createOutage(MockService svc, Event svcLostEvent) {
  createOutage(svc, svcLostEvent.getDbid(), new Timestamp(svcLostEvent.getTime().getTime()));
}

代码示例来源:origin: OpenNMS/opennms

public void resolveOutage(MockService svc, Event svcRegainEvent) {
  resolveOutage(svc, svcRegainEvent.getDbid(), new Timestamp(svcRegainEvent.getTime().getTime()));
}

代码示例来源:origin: org.opennms.core.test-api/org.opennms.core.test-api.db

public void resolveOutage(MockService svc, Event svcRegainEvent) {
  resolveOutage(svc, svcRegainEvent.getDbid(), new Timestamp(svcRegainEvent.getTime().getTime()));
}

代码示例来源:origin: org.opennms.core.test-api/org.opennms.core.test-api.db

public void createOutage(MockService svc, Event svcLostEvent) {
  createOutage(svc, svcLostEvent.getDbid(), new Timestamp(svcLostEvent.getTime().getTime()));
}

代码示例来源:origin: OpenNMS/opennms

OutageChecker(MockService svc, Event lostSvcEvent,
    Event regainedSvcEvent) {
  super(m_db,
      "select * from outages where nodeid = ? and ipAddr = ? and serviceId = ?");
  m_svc = svc;
  m_lostSvcEvent = lostSvcEvent;
  m_lostSvcTime = new Timestamp(m_lostSvcEvent.getTime().getTime());
  m_regainedSvcEvent = regainedSvcEvent;
  if (m_regainedSvcEvent != null) {
    m_regainedSvcTime = new Timestamp(m_regainedSvcEvent.getTime().getTime());
  }
}

代码示例来源:origin: OpenNMS/opennms

OutageChecker(MockService svc, Event lostSvcEvent,
       Event regainedSvcEvent) {
  super(m_db, "select * from outages where nodeid = ? and ipAddr = ? and serviceId = ?");
  m_svc = svc;
  m_lostSvcEvent = lostSvcEvent;
  m_lostSvcTime = new Timestamp(m_lostSvcEvent.getTime().getTime());
  m_regainedSvcEvent = regainedSvcEvent;
  if (m_regainedSvcEvent != null) {
    m_regainedSvcTime = new Timestamp(m_regainedSvcEvent.getTime().getTime());
  }
}

代码示例来源:origin: stackoverflow.com

Event event = events.get(position);
holder.resname.setText(event.getResturant());
 holder.resadd.setText(event.getAddress());
 holder.restim.setText(event.getTime());
 holder.imageView.setImageResource(event.getImage());

代码示例来源:origin: OpenNMS/opennms

private synchronized void closeExpectedOutages(Event e, Outage pendingOutage) {
  for (Outage outage : m_expectedOutages) {
    if (pendingOutage.equals(outage)) {
      outage.setRegainedEvent(e.getDbid(), new Timestamp(e.getTime().getTime()));
    }
  }
}

代码示例来源:origin: OpenNMS/opennms

@Override
public synchronized void onEvent(Event e) {
  for (Outage outage : getOutageList(m_pendingOpens, e)) {
    outage.setLostEvent(e.getDbid(), new Timestamp(e.getTime().getTime()));
    m_expectedOutages.add(outage);
  }
  clearOutageList(m_pendingOpens, e);
  
  for (Outage outage : getOutageList(m_pendingCloses, e)) {
    closeExpectedOutages(e, outage);
  }
  clearOutageList(m_pendingCloses, e);
}

代码示例来源:origin: OpenNMS/opennms

/**
 * {@inheritDoc}
 *
 * The method that inserts the event into the database
 */
private void process(final Header eventHeader, final Event event) throws EventProcessorException {
  LOG.debug("HibernateEventWriter: processing {}, nodeid: {}, ipaddr: {}, serviceid: {}, time: {}", event.getUei(), event.getNodeid(), event.getInterface(), event.getService(), event.getTime());
  try {
    final OnmsEvent ovent = createOnmsEvent(eventHeader, event);
    eventDao.save(ovent);
    // Update the event with the database ID of the event stored in the database
    event.setDbid(ovent.getId());
  } catch (DeadlockLoserDataAccessException e) {
    throw new EventProcessorException("Encountered deadlock when inserting event: " + event.toString(), e);
  } catch (Throwable e) {
    throw new EventProcessorException("Unexpected exception while storing event: " + event.toString(), e);
  }
}

代码示例来源:origin: OpenNMS/opennms

@Test
public void testBug1114() throws Exception {
  // XXX Needing to bump up this number is bogus
  m_anticipator.setExpectedDifference(5000);
        MockService svc = m_network.getService(1, "192.168.1.1", "ICMP");
  
  long interval = computeInterval();
  Event event = MockEventUtil.createServiceEvent("Test", "uei.opennms.org/tests/nodeTimeTest", svc, null);
  
  Date date = event.getTime();
  String dateString = DateFormat.getDateTimeInstance(DateFormat.FULL,
          DateFormat.FULL).format(date);
  long endTime = anticipateNotificationsForGroup("time " + dateString + ".", "Timestamp: " + dateString + ".", "InitialGroup", date, interval);
  m_eventMgr.sendEventToListeners(event);
  // XXX Needing to decrease the end time is bogus
  verifyAnticipated(endTime - 5000, 1000);
}

相关文章