diff --git a/scheduler.cron.inc b/scheduler.cron.inc
index b7a61d5..511e979 100644
--- a/scheduler.cron.inc
+++ b/scheduler.cron.inc
@@ -18,6 +18,7 @@ use Drupal\node\Entity\Node;
  *   TRUE if any node has been published, FALSE otherwise.
  */
 function _scheduler_publish() {
+  $date_formatter = \Drupal::service('date.formatter');
   $result = FALSE;

   // If the time now is greater than the time to publish a node, publish it.
@@ -58,8 +59,8 @@ function _scheduler_publish() {
       $node->setNewRevision();
       // Use a core date format to guarantee a time is included.
       $node->revision_log = t('Node published by Scheduler on @now. Previous creation date was @date.', array(
-        '@now' => \Drupal::service('date.formatter')->format(REQUEST_TIME, 'short'),
-        '@date' => \Drupal::service('date.formatter')->format($old_creation_date, 'short'),
+        '@now' => $date_formatter->format(REQUEST_TIME, 'short'),
+        '@date' => $date_formatter->format($old_creation_date, 'short'),
       ));
     }
     // Unset publish_on so the node will not get rescheduled by subsequent calls
@@ -99,6 +100,7 @@ function _scheduler_publish() {
  *   TRUE is any node has been unpublished, FALSE otherwise.
  */
 function _scheduler_unpublish() {
+  $date_formatter = \Drupal::service('date.formatter');
   $result = FALSE;

   // If the time is greater than the time to unpublish a node, unpublish it.
@@ -144,8 +146,8 @@ function _scheduler_unpublish() {
       $node->setNewRevision();
       // Use a core date format to guarantee a time is included.
       $node->revision_log = t('Node unpublished by Scheduler on @now. Previous change date was @date.', array(
-        '@now' => \Drupal::service('date.formatter')->format(REQUEST_TIME, 'short'),
-        '@date' => \Drupal::service('date.formatter')->format($old_change_date, 'short'),
+        '@now' => $date_formatter->format(REQUEST_TIME, 'short'),
+        '@date' => $date_formatter->format($old_change_date, 'short'),
       ));
     }
     // Unset unpublish_on so the node will not get rescheduled by subsequent
diff --git a/scheduler.edit.inc b/scheduler.edit.inc
index f6121f7..1342fba 100644
--- a/scheduler.edit.inc
+++ b/scheduler.edit.inc
@@ -17,6 +17,7 @@ use Drupal\Core\Form\FormStateInterface;
  * @see scheduler_form_alter()
  */
 function _scheduler_form_alter(array &$form, FormStateInterface $form_state) {
+  $date_formatter = \Drupal::service('date.formatter');
   /** @var \Drupal\node\NodeTypeInterface $type */
   $type = $form_state->getFormObject()->getEntity()->type->entity;
   $publishing_enabled = $type->getThirdPartySetting('scheduler', 'publish_enable', FALSE);
@@ -66,13 +67,13 @@ function _scheduler_form_alter(array &$form, FormStateInterface $form_state) {
   $descriptions = array();
   if ($date_only_allowed && ($date_only_format != $date_format)) {
     $descriptions['format'] = t('Format: %date_only_format or %standard_format.', array(
-      '%date_only_format' => \Drupal::service('date.formatter')->format(time(), 'custom', $date_only_format),
-      '%standard_format' => \Drupal::service('date.formatter')->format(time(), 'custom', $date_format),
+      '%date_only_format' => $date_formatter->format(time(), 'custom', $date_only_format),
+      '%standard_format' => $date_formatter->format(time(), 'custom', $date_format),
     ));
   }
   else {
     $descriptions['format'] = t('Format: %standard_format.', array(
-      '%standard_format' => \Drupal::service('date.formatter')->format(time(), 'custom', $date_format),
+      '%standard_format' => $date_formatter->format(time(), 'custom', $date_format),
     ));
   }
   // Show the default time so users know what they will get if they do not
@@ -80,7 +81,7 @@ function _scheduler_form_alter(array &$form, FormStateInterface $form_state) {
   if ($date_only_allowed) {
     $default_time = strtotime(\Drupal::config('scheduler.settings')->get('default_time'));
     $descriptions['default'] = t('The default time is @default_time.', array(
-      '@default_time' => \Drupal::service('date.formatter')->format($default_time, 'custom', $time_only_format ? $time_only_format : SCHEDULER_TIME_ONLY_FORMAT),
+      '@default_time' => $date_formatter->format($default_time, 'custom', $time_only_format ? $time_only_format : SCHEDULER_TIME_ONLY_FORMAT),
     ));
   }

diff --git a/scheduler.module b/scheduler.module
index 1865d15..2cd6a1a 100644
--- a/scheduler.module
+++ b/scheduler.module
@@ -342,19 +342,24 @@ function scheduler_node_validate($node, array $form, FormStateInterface $form_st
   // already converted. This is needed because Drupal 6 removed 'submit' and
   // added 'presave' and all this happens at different times.
   $date_format = \Drupal::config('scheduler.settings')->get('date_format');
+  $date_formatter = \Drupal::service('date.formatter');
   $entity = $node->type->entity;

   if (!empty($node->publish_on->value) && !is_numeric($node->publish_on->value)) {
     $publishtime = $node->publish_on->value;
     if ($publishtime === FALSE) {
-      $form_state->setErrorByName('publish_on', t("The 'publish on' value does not match the expected format of %time", array('%time' => \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', $date_format))));
+      $form_state->setErrorByName('publish_on', t("The 'publish on' value does not match the expected format of %time",
+        array('%time' => $date_formatter->format(REQUEST_TIME, 'custom', $date_format))
+      ));
     }
   }

   if (!empty($node->unpublish_on->value) && !is_numeric($node->unpublish_on->value)) {
     $unpublishtime = $node->unpublish_on->value;
     if ($unpublishtime === FALSE) {
-      $form_state->setErrorByName('unpublish_on', t("The 'unpublish on' value does not match the expected format of %time", array('%time' => \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', $date_format))));
+      $form_state->setErrorByName('unpublish_on', t("The 'unpublish on' value does not match the expected format of %time",
+        array('%time' => $date_formatter->format(REQUEST_TIME, 'custom', $date_format))
+      ));
     }
   }
 }
@@ -363,6 +368,7 @@ function scheduler_node_validate($node, array $form, FormStateInterface $form_st
  * Implements hook_ENTITY_TYPE_presave() for node entities.
  */
 function scheduler_node_presave(EntityInterface $node) {
+  $date_formatter = \Drupal::service('date.formatter');
   if ($node->publish_on->value > 0) {
     // Check that other modules allow the action on this node.
     $publication_allowed = _scheduler_allow($node, 'publish');
@@ -390,7 +396,8 @@ function scheduler_node_presave(EntityInterface $node) {
       // message themselves explaining why publication is denied.
       if ($publication_allowed) {
         $date_format = \Drupal::config('scheduler.settings')->get('date_format');
-        drupal_set_message(t('This post is unpublished and will be published @publish_time.', array('@publish_time' => \Drupal::service('date.formatter')->format($node->publish_on->value, 'custom', $date_format))), 'status', FALSE);
+        drupal_set_message(t('This post is unpublished and will be published @publish_time.',
+          array('@publish_time' => $date_formatter->format($node->publish_on->value, 'custom', $date_format))), 'status', FALSE);
       }
     }
   }
@@ -552,14 +559,15 @@ function scheduler_field_extra_fields() {
  * @see template_preprocess_node()
  */
 function scheduler_preprocess_node(&$variables) {
+  $date_formatter = \Drupal::service('date.formatter');
   /* @var $node \Drupal\node\NodeInterface */
   $node = $variables['node'];
   $date_format = \Drupal::config('scheduler.settings')->get('date_format');
   if (!empty($node->publish_on->value) && $node->publish_on->value && is_numeric($node->publish_on->value)) {
-    $variables['publish_on'] = \Drupal::service('date.formatter')->format($node->publish_on->value, 'custom', $date_format);
+    $variables['publish_on'] = $date_formatter->format($node->publish_on->value, 'custom', $date_format);
   }
   if (!empty($node->unpublish_on->value) && $node->unpublish_on->value && is_numeric($node->unpublish_on->value)) {
-    $variables['unpublish_on'] = \Drupal::service('date.formatter')->format($node->unpublish_on->value, 'custom', $date_format);
+    $variables['unpublish_on'] = $date_formatter->format($node->unpublish_on->value, 'custom', $date_format);
   }
 }

diff --git a/scheduler.tokens.inc b/scheduler.tokens.inc
index 5bcff5b..e8c5840 100644
--- a/scheduler.tokens.inc
+++ b/scheduler.tokens.inc
@@ -29,6 +29,7 @@ function scheduler_token_info() {
  * Implements hook_tokens().
  */
 function scheduler_tokens($type, $tokens, array $data = array(), array $options = array()) {
+  $date_formatter = \Drupal::service('date.formatter');
   $language_code = isset($options['language']) ? $options['language']->language : NULL;
   $replacements = array();

@@ -39,12 +40,12 @@ function scheduler_tokens($type, $tokens, array $data = array(), array $options
       switch ($name) {
         case 'scheduler-publish':
           if (isset($node->publish_on->value)) {
-            $replacements[$original] = \Drupal::service('date.formatter')->format($node->publish_on->value, 'medium', '', NULL, $language_code);
+            $replacements[$original] = $date_formatter->format($node->publish_on->value, 'medium', '', NULL, $language_code);
           }
           break;
         case 'scheduler-unpublish':
           if (isset($node->unpublish_on->value)) {
-            $replacements[$original] = \Drupal::service('date.formatter')->format($node->unpublish_on->value, 'medium', '', NULL, $language_code);
+            $replacements[$original] = $date_formatter->format($node->unpublish_on->value, 'medium', '', NULL, $language_code);
           }
           break;
       }
diff --git a/src/Form/SchedulerAdminForm.php b/src/Form/SchedulerAdminForm.php
index f6d7335..de6cddb 100644
--- a/src/Form/SchedulerAdminForm.php
+++ b/src/Form/SchedulerAdminForm.php
@@ -7,10 +7,13 @@

 namespace Drupal\scheduler\Form;

+use Drupal\Core\Config\ConfigFactoryInterface;
+use Drupal\Core\Datetime\DateFormatterInterface;
 use Drupal\Core\Form\ConfigFormBase;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Render\Element;
 use Drupal\Core\Url;
+use Symfony\Component\DependencyInjection\ContainerInterface;

 /**
  * Main administration form for the Scheduler module.
@@ -18,6 +21,35 @@ use Drupal\Core\Url;
 class SchedulerAdminForm extends ConfigFormBase {

   /**
+   * The date formatter service.
+   *
+   * @var \Drupal\Core\Datetime\DateFormatterInterface
+   */
+  protected $dateFormatter;
+
+  /**
+   * {@inheritdoc}
+   *
+   * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
+   *   The date formatter service.
+   */
+  public function __construct(ConfigFactoryInterface $config_factory, DateFormatterInterface $date_formatter) {
+    $this->dateFormatter = $date_formatter;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container) {
+    return new static(
+      $container->get('config.factory'),
+      $container->get('date.formatter')
+    );
+  }
+
+
+  /**
    * {@inheritdoc}
    */
   public function getFormId() {
@@ -36,7 +68,7 @@ class SchedulerAdminForm extends ConfigFormBase {
    */
   public function buildForm(array $form, FormStateInterface $form_state) {
     $config = $this->config('scheduler.settings');
-    $now = t('Example: %date', ['%date' => \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', $config->get('date_format'))]);
+    $now = t('Example: %date', ['%date' => $this->dateFormatter->format(REQUEST_TIME, 'custom', $config->get('date_format'))]);
     $url = Url::fromUri('http://php.net/manual/en/function.date.php');
     $form['date_format'] = [
       '#type' => 'textfield',
@@ -113,7 +145,7 @@ class SchedulerAdminForm extends ConfigFormBase {
       else {
         // Insert any possibly omitted leading zeroes.
         $unix_time = mktime($default_time['hour'], $default_time['minute'], $default_time['second']);
-        $form_state->setValue(['default_time'], \Drupal::service('date.formatter')->format($unix_time, 'custom', 'H:i:s'));
+        $form_state->setValue(['default_time'], $this->dateFormatter->format($unix_time, 'custom', 'H:i:s'));
       }
     }

