예제 #1
0
  private void updateTime(NtpBindingProvider provider, String itemName, long networkTimeInMillis) {
    TimeZone timeZone = provider.getTimeZone(itemName);
    Locale locale = provider.getLocale(itemName);

    Calendar calendar = Calendar.getInstance(timeZone, locale);
    calendar.setTimeInMillis(networkTimeInMillis);

    eventPublisher.postUpdate(itemName, new DateTimeType(calendar));
  }
예제 #2
0
  /** @{inheritDoc} */
  @Override
  public void execute() {

    if (!bindingsExist()) {
      logger.debug("There is no existing NTP binding configuration => refresh cycle aborted!");
      return;
    }

    long networkTimeInMillis = getTime(hostname);

    logger.debug("Got time from {}: {}", hostname, SDF.format(new Date(networkTimeInMillis)));

    for (NtpBindingProvider provider : providers) {
      for (String itemName : provider.getItemNames()) {
        updateTime(provider, itemName, networkTimeInMillis);
      }
    }
  }