From 6efdf7d39e2688d0953ecb76177c0f2f339f2504 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Fri, 23 Aug 2024 01:54:27 +0200 Subject: [PATCH] Fixed LocalDateTime to ZonedDateTime. --- src/fr/devinsy/util/rss/RSSElement.java | 52 +++++++++++------------ src/fr/devinsy/util/rss/demo/RSSDemo.java | 4 +- 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/src/fr/devinsy/util/rss/RSSElement.java b/src/fr/devinsy/util/rss/RSSElement.java index e13e94a..5eaed0d 100644 --- a/src/fr/devinsy/util/rss/RSSElement.java +++ b/src/fr/devinsy/util/rss/RSSElement.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2014,2017 Christian Pierre MOMON + * Copyright (C) 2013-2024 Christian Pierre MOMON * * This file is part of Devinsy-rss. * @@ -18,13 +18,11 @@ */ package fr.devinsy.util.rss; -import java.time.LocalDateTime; +import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; /** * The Class RSSElement. - * - * @author Christian Pierre MOMON (christian.momon@devinsy.fr) */ public class RSSElement { @@ -34,29 +32,6 @@ public class RSSElement private String value; private String[] attributes; - /** - * Instantiates a new RSS element. - * - * @param name - * the name - * @param value - * the value - */ - public RSSElement(final String name, final LocalDateTime value) - { - setName(name); - if (value == null) - { - this.value = null; - } - else - { - - this.value = value.format(DateTimeFormatter.ofPattern(DATE_PATTERN)); - } - this.attributes = null; - } - /** * Instantiates a new RSS element. * @@ -121,6 +96,28 @@ public class RSSElement this.attributes = attributes; } + /** + * Instantiates a new RSS element. + * + * @param name + * the name + * @param value + * the value + */ + public RSSElement(final String name, final ZonedDateTime value) + { + setName(name); + if (value == null) + { + this.value = null; + } + else + { + this.value = value.format(DateTimeFormatter.ofPattern(DATE_PATTERN)); + } + this.attributes = null; + } + /** * Gets the attributes. * @@ -190,5 +187,4 @@ public class RSSElement { this.value = value; } - } diff --git a/src/fr/devinsy/util/rss/demo/RSSDemo.java b/src/fr/devinsy/util/rss/demo/RSSDemo.java index caec3cc..58af4b8 100644 --- a/src/fr/devinsy/util/rss/demo/RSSDemo.java +++ b/src/fr/devinsy/util/rss/demo/RSSDemo.java @@ -19,7 +19,7 @@ package fr.devinsy.util.rss.demo; import java.io.IOException; -import java.time.LocalDateTime; +import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; @@ -64,7 +64,7 @@ public class RSSDemo // List elements = new ArrayList(); - LocalDateTime now = LocalDateTime.now(); + ZonedDateTime now = ZonedDateTime.now(); elements.add(new RSSElement("pubDate", now)); elements.add(new RSSElement("lastBuildDate", now)); elements.add(new RSSElement("generator", "Generated by Foo"));